Runbook: Migrations Failing
Trigger
make migratefails.make migration name=...generates incorrect diff.- App startup fails due to DB schema mismatch.
Fast triage
- Confirm
.envpoints at the DB you expect (SQLITE_DB_PATH). - Run migration command explicitly:
make migrate. - Inspect current migration heads:
.venv/bin/python -m alembic heads.
Most common causes
- Model changes were made but migration not generated.
- Migration was built with stale or wrong model imports.
- Wrong DB file/path in
.env. - Someone changed the DB by hand; history no longer matches Alembic.
Recovery steps
- Confirm model import chain includes new/changed model.
- Generate migration from current models:
make migration name=describe_change. - Review generated file in
alembic/versions/. - Apply migration:
make migrate. - Re-run tests:
make test.
Safe rollback strategy (local)
- If the file is wrong and nobody else has it yet, delete it and generate again with fixed models/imports.
- Do not rewrite shared migration history without team agreement.
Exit criteria
make migratepasses.- App starts and uses expected schema.
make testpasses.
Follow-up
- If the schema policy is non-obvious, capture it in an ADR.
Page history
| Date | Change | Author |
|---|---|---|
| Added Page history section (repository baseline). | Ivan Boyarkin |