Remove backwards compat code: no installed base pre-1.0
All checks were successful
check / check (push) Successful in 1m49s
All checks were successful
check / check (push) Successful in 1m49s
- Simplify bootstrapMigrationsTable to just check table existence and apply 000.sql if missing — no legacy DB detection - Remove ensureBootstrapVersionRecorded (legacy backfill path) - Remove applyBootstrapMigration (separate helper, now inlined) - Remove TestBootstrapMigrationsTable_ExistingTableBackwardsCompat - Simplify 000.sql header comment
This commit is contained in:
@@ -222,58 +222,3 @@ func TestBootstrapMigrationsTable_FreshDatabase(t *testing.T) {
|
||||
t.Errorf("expected version 000 to be recorded, got count %d", recorded)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBootstrapMigrationsTable_ExistingTableBackwardsCompat(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
// Simulate an older database that created the table via inline SQL
|
||||
// (without recording version "000").
|
||||
_, err := db.Exec(`
|
||||
CREATE TABLE schema_migrations (
|
||||
version TEXT PRIMARY KEY,
|
||||
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
)
|
||||
`)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create legacy table: %v", err)
|
||||
}
|
||||
|
||||
// Insert a fake migration to prove the table already existed.
|
||||
_, err = db.Exec("INSERT INTO schema_migrations (version) VALUES ('001')")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to insert legacy version: %v", err)
|
||||
}
|
||||
|
||||
if err := bootstrapMigrationsTable(ctx, db, nil); err != nil {
|
||||
t.Fatalf("bootstrapMigrationsTable failed: %v", err)
|
||||
}
|
||||
|
||||
// Version "000" must now be recorded.
|
||||
var recorded int
|
||||
|
||||
err = db.QueryRow(
|
||||
"SELECT COUNT(*) FROM schema_migrations WHERE version = '000'",
|
||||
).Scan(&recorded)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to check version: %v", err)
|
||||
}
|
||||
|
||||
if recorded != 1 {
|
||||
t.Errorf("expected version 000 to be recorded for legacy DB, got count %d", recorded)
|
||||
}
|
||||
|
||||
// The existing "001" row must still be there.
|
||||
var legacyCount int
|
||||
|
||||
err = db.QueryRow(
|
||||
"SELECT COUNT(*) FROM schema_migrations WHERE version = '001'",
|
||||
).Scan(&legacyCount)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to check legacy version: %v", err)
|
||||
}
|
||||
|
||||
if legacyCount != 1 {
|
||||
t.Errorf("legacy version 001 row missing after bootstrap")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user