Move schema_migrations table creation into 000.sql with INTEGER version column
All checks were successful
check / check (pull_request) Successful in 2m30s
All checks were successful
check / check (pull_request) Successful in 2m30s
Replace the monolithic schema.sql embed with a numbered migration system following the pixa pattern: - Add schema/000.sql: bootstrap migration creating schema_migrations table with INTEGER PRIMARY KEY version column and applied_at timestamp - Move full schema to schema/001.sql (renamed from schema.sql) - Remove redundant schema/008_uploads.sql (uploads table already in main schema) - Rewrite database.go migration logic: - Embed schema/*.sql directory instead of single schema.sql - bootstrapMigrationsTable() checks for table existence, applies 000.sql - applyMigrations() iterates numbered files, skips already-applied versions - ParseMigrationVersion() extracts version from filenames (e.g. 001.sql) - Go code does zero INSERTs for bootstrap — 000.sql is self-contained - Update database_test.go to verify schema_migrations table exists
This commit is contained in:
9
internal/database/schema/000.sql
Normal file
9
internal/database/schema/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