forked from sneak/upaas
Move schema_migrations table creation into 000.sql with INTEGER version column
Refactors the migration system to follow the pixa pattern: - Add 000.sql bootstrap migration that creates schema_migrations with INTEGER PRIMARY KEY version column - Go code no longer creates the migrations table inline; it reads and executes 000.sql as a bootstrap step before the normal migration loop - Export ParseMigrationVersion and ApplyMigrations for test use - Add legacy TEXT-to-INTEGER conversion for existing databases that stored migration versions as filenames (e.g. '001_initial.sql') - Wrap individual migration application in transactions for safety - Add comprehensive tests for version parsing, fresh database bootstrap, idempotent re-application, and legacy conversion
This commit is contained in:
9
internal/database/migrations/000.sql
Normal file
9
internal/database/migrations/000.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- Migration 000: Schema migrations tracking table
|
||||
-- Applied as a bootstrap step before the normal migration loop.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS schema_migrations (
|
||||
version INTEGER PRIMARY KEY,
|
||||
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
INSERT OR IGNORE INTO schema_migrations (version) VALUES (0);
|
||||
Reference in New Issue
Block a user