new-migration
Create and validate an Alembic migration safely. Use when changing the database schema.
SKILL.md.claude/skills/new-migration/SKILL.md
GitHubCreate a safe Alembic migration for: $ARGUMENTS
Step 1 — Verify current state
alembic current
alembic history --verbose
Step 2 — Generate migration
alembic revision --autogenerate -m "$ARGUMENTS"
Step 3 — Review the generated file
Read the generated migration file carefully. Check:
-
upgrade()does exactly what's needed -
downgrade()properly reverses the upgrade - No accidental table drops or column removals
- ForeignKey constraints have correct
ondeleterules - Indexes are created for all FK columns and frequently filtered columns
- Enum types are handled correctly for MySQL
Step 4 — Test upgrade
alembic upgrade head
Step 5 — Test downgrade
alembic downgrade -1
alembic upgrade head
Step 6 — Confirm
Report:
- Migration file path
- What it does (upgrade)
- What it undoes (downgrade)
- Any manual steps needed (e.g. data migration)
IMPORTANT: Never modify a migration that has already been applied to staging or production. Create a new migration instead.
$ARGUMENTS