| name | create-migration |
| description | Create and validate an Alembic database migration |
| disable-model-invocation | true |
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.py for recent modifications
-
Generate the migration:
cd 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
-
Show the migration to the user for approval before proceeding
-
Test the migration applies cleanly:
cd 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