Description
The database schema is applied raw on initialization with no version tracking or migration system. Any schema change requires manual intervention or data loss. There is no way to evolve the schema while preserving existing data.
Current State
- ✅ Schema defined in
public/db/schema.sql
- ❌ No migration version tracking table
- ❌ No migration scripts
- ❌ No
db:migrate CLI command
- ❌ Schema changes require dropping and recreating the database
Proposed Implementation
- Add a
schema_version table to track applied migrations
- Create a migration framework that runs pending migrations on app startup
- Number migrations sequentially (e.g.,
001_initial.sql, 002_add_xxx.sql)
- Add
db:migrate, db:rollback, db:status CLI commands
- Add database backup before migration
- Support both up and down migrations
Acceptance Criteria
Description
The database schema is applied raw on initialization with no version tracking or migration system. Any schema change requires manual intervention or data loss. There is no way to evolve the schema while preserving existing data.
Current State
public/db/schema.sqldb:migrateCLI commandProposed Implementation
schema_versiontable to track applied migrations001_initial.sql,002_add_xxx.sql)db:migrate,db:rollback,db:statusCLI commandsAcceptance Criteria
schema_versiontable tracks applied migrationsdb:migrateCLI command availabledb:backupCLI command creates a backup before migration