Create Migration
Generate a new Alembic migration for database schema changes.
Arguments
- •
description(required): Short description for the migration (e.g., "add image checksum column")
Steps
- •
Verify there are pending model changes by checking
api/app/models.pyfor recent modifications - •
Generate the migration:
bashcd api && alembic revision --autogenerate -m "<description>"
- •
Read the generated migration file and review it for correctness:
- •Verify
upgrade()contains the expected DDL operations - •Verify
downgrade()properly reverses all changes - •Check for any autogenerate false positives (e.g., index ordering changes)
- •Remove any no-op operations
- •Verify
- •
Show the migration to the user for approval before proceeding
- •
Test the migration applies cleanly:
bashcd api && alembic upgrade head
- •
Report success and the migration file path
Conventions
- •Migration descriptions use lowercase, no period (e.g., "add node placement host_id column")
- •One migration per logical change — don't combine unrelated schema changes
- •Always verify downgrade path works