[Infra] SQLite migration runner — Rails-style numbered migrations per user DB #43
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Circuit-Forge/peregrine#43
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Implement a lightweight, Rails-inspired migration system for
staging.db. Each cloud user and self-hosted instance has their own SQLite file; migrations must apply to each DB independently on first use after a deploy.Design
migrations/directory — numbered.sqlfiles (001_baseline.sql,002_add_xyz.sql)schema_migrationstable in each DB tracks applied versionsscripts/db_migrate.py—migrate_db(db_path)runner called at API startupCREATE TABLE IF NOT EXISTSeverywhere so existing DBs silently skip itChecklist
scripts/db_migrate.pywithmigrate_db(db_path: Path)runnermigrations/001_baseline.sqlcapturing current full schemamigrate_db()intodev_api.pylifespan startupmigrate_db()into Streamlitapp.pystartup.sqlfiledocs/contributing.mdWhy not Alembic?
Alembic assumes a single shared DB. Here each user has their own file — migrations must be lazy (run on first request) and path-agnostic. A ~50-line custom runner fits better than pulling in SQLAlchemy for this.
Implemented in
64554db. Rails-style numbered SQL migration runner:migrations/001_baseline.sql— full schema baselinescripts/db_migrate.py— runner withschema_migrationstracking