Migrations¶
Alembic is the only way to change the schema. Design reference:
spec_v3.md ยง3.8 Schema Migration.
Layout¶
Common Operations¶
# Apply everything
alembic upgrade head
# Roll back one
alembic downgrade -1
# Generate from model changes
alembic revision --autogenerate -m "descriptive message"
# Show current revision
alembic current
# Show history
alembic history --verbose
Authoring¶
See Workflow โ Add a Migration for the full recipe.
Recovery¶
If a migration fails mid-flight:
- Inspect
alembic current. - Fix the model / migration file.
alembic downgrade -1to the known-good state.- Re-run
alembic upgrade head.
Full disaster recovery: Operations โ Backup & Recovery.