diff --git a/AGENTS.md b/AGENTS.md index fe20cce0d..c98cb7a3b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -165,7 +165,7 @@ type Driver interface { 4. Demo mode: Seed with demo data **Schema Versioning:** -- Stored in `instance_setting` table (key: `bb.general.version`) +- Stored in `system_setting` table - Format: `major.minor.patch` - Migration files: `store/migration/{driver}/{version}/NN__description.sql` - See: `store/migrator.go:21-414` @@ -503,13 +503,6 @@ cd web && pnpm lint ## Common Tasks -### Debugging Database Issues - -1. Check connection string in logs -2. Verify `store/db/{driver}/migration/` files exist -3. Check schema version: `SELECT * FROM instance_setting WHERE key = 'bb.general.version'` -4. Test migration: `go test ./store/test/... -v` - ### Debugging API Issues 1. Check Connect interceptor logs: `server/router/api/v1/connect_interceptors.go:79-105` diff --git a/store/migrator.go b/store/migrator.go index d5446fcab..1a8bb5d39 100644 --- a/store/migrator.go +++ b/store/migrator.go @@ -21,7 +21,7 @@ import ( // Migration System Overview: // // The migration system handles database schema versioning and upgrades. -// Schema version is stored in instance_setting (formerly system_setting). +// Schema version is stored in system_setting. // // Migration Flow: // 1. preMigrate: Check if DB is initialized. If not, apply LATEST.sql @@ -30,9 +30,9 @@ import ( // 4. Migrate (demo mode): Seed database with demo data // // Version Tracking: -// - New installations: Schema version set in instance_setting immediately -// - Existing v0.22+ installations: Schema version tracked in instance_setting -// - Pre-v0.22 installations: Must upgrade to v0.25.x first (migration_history → instance_setting migration) +// - New installations: Schema version set in system_setting immediately +// - Existing v0.22+ installations: Schema version tracked in system_setting +// - Pre-v0.22 installations: Must upgrade to v0.25.x first (migration_history → system_setting migration) // // Migration Files: // - Location: store/migration/{driver}/{version}/NN__description.sql @@ -373,7 +373,7 @@ func (s *Store) updateCurrentSchemaVersion(ctx context.Context, schemaVersion st // checkMinimumUpgradeVersion verifies the installation meets minimum version requirements for upgrade. // For very old installations (< v0.22.0), users must upgrade to v0.25.x first before upgrading to current version. -// This is necessary because schema version tracking was moved from migration_history to instance_setting in v0.22.0. +// This is necessary because schema version tracking was moved from migration_history to system_setting in v0.22.0. func (s *Store) checkMinimumUpgradeVersion(ctx context.Context) error { instanceBasicSetting, err := s.GetInstanceBasicSetting(ctx) if err != nil { @@ -401,7 +401,7 @@ func (s *Store) checkMinimumUpgradeVersion(ctx context.Context) error { "2. Start the server and verify it works\n"+ "3. Then upgrade to the latest version\n\n"+ "This is required because schema version tracking was moved from migration_history\n"+ - "to instance_setting in v0.22.0. The intermediate upgrade handles this migration safely.", + "to system_setting in v0.22.0. The intermediate upgrade handles this migration safely.", schemaVersion, currentVersion, ) diff --git a/store/seed/sqlite/01__dump.sql b/store/seed/sqlite/01__dump.sql index c42ee5181..457703998 100644 --- a/store/seed/sqlite/01__dump.sql +++ b/store/seed/sqlite/01__dump.sql @@ -36,4 +36,4 @@ INSERT INTO reaction (id,creator_id,content_id,reaction_type) VALUES(4,1,'memos/ INSERT INTO reaction (id,creator_id,content_id,reaction_type) VALUES(5,1,'memos/sponsor0000001','👍'); -- System Settings -INSERT INTO instance_setting VALUES ('MEMO_RELATED', '{"contentLengthLimit":8192,"enableAutoCompact":true,"enableComment":true,"enableLocation":true,"defaultVisibility":"PUBLIC","reactions":["👍","💛","🔥","👏","😂","👌","🚀","👀","🤔","🤡","❓","+1","🎉","💡","✅"]}', ''); +INSERT INTO system_setting VALUES ('MEMO_RELATED', '{"contentLengthLimit":8192,"enableAutoCompact":true,"enableComment":true,"enableLocation":true,"defaultVisibility":"PUBLIC","reactions":["👍","💛","🔥","👏","😂","👌","🚀","👀","🤔","🤡","❓","+1","🎉","💡","✅"]}', '');