Phase 9, part 3: schema migrations for both databases

Migrations from schema 30 on are one list (internal/db/migrations.go),
written in SQLite's SQL and translated for Postgres (db.PostgresSQL)
unless one gives its own. On Postgres the whole migration is one
transaction under an advisory lock, and each step is recorded in
schema_migrations. TestSchemasMatch compares the two schemas (tables,
columns, types, NOT NULL, nocase, indexes), with and without a new
migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 07:17:56 -07:00
co-authored by Claude Opus 5.5
parent 1b2947de7c
commit d827d507c1
9 changed files with 508 additions and 32 deletions
+4
View File
@@ -155,11 +155,15 @@ func run(log *slog.Logger) error {
}
return err
}
db.AppVersion = version
database, err := db.Open(filepath.Join(dataDir, "app.db"))
if err != nil {
return err
}
defer database.Close()
if database.MigratedFrom > 0 {
log.Info("database: migrated", "database", database.Dialect, "from", database.MigratedFrom, "to", db.Schema())
}
if n, err := content.RecoverInterrupted(database); err != nil {
return err