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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user