| name | migration-gen |
| description | Generates a database migration file for schema changes |
| argument-hint | <description-of-change> |
| user-invocable | true |
| allowed-tools | Read Glob Bash Edit |
| effort | low |
Generate Database Migration
Change: $ARGUMENTS
- Detect ORM/migration tool:
cat package.json | grep -E '"prisma"|"drizzle"|"typeorm"|"knex"|"sequelize"|"migrate"'
ls prisma/ migrations/ db/migrations/ 2>/dev/null | head -10
- Read the current schema:
cat prisma/schema.prisma 2>/dev/null || ls migrations/ 2>/dev/null | tail -3 | xargs -I{} cat migrations/{}
-
Generate the migration based on the requested change:
- Additive changes (new table, new column with default) - safe
- Destructive changes (drop column, rename) - add warning and suggest renaming strategy
- Data migrations - separate from schema migrations
-
For Prisma: generate migration name and schema change, then ask to run:
npx prisma migrate dev --name $ARGUMENTS
For raw SQL: generate up/down migration files.
-
Always generate a down migration (rollback).
-
Flag any changes that require a deployment strategy (e.g., add-then-backfill, not rename directly).