db-migrate

Use when creating, applying, rolling back, or checking the status of database migrations.

Database Migration

Create, apply, and manage database migrations.

Arguments

  • /db-migrate create <name> — create new migration
  • /db-migrate apply — apply pending migrations
  • /db-migrate status — show migration status
  • /db-migrate rollback — rollback last migration

Workflow

Step 1: Detect ORM/Migration Tool

Search for: prisma/schema.prisma, ormconfig.*, data-source.ts, knexfile.*, .sequelizerc, drizzle.config.ts, alembic.ini, migrations/ with raw SQL.

Step 2: Execute Command

Create:

ToolCommand
Prismanpx prisma migrate dev --name <name>
TypeORMnpx typeorm migration:generate -n <name>
Knexnpx knex migrate:make <name>
Sequelizenpx sequelize-cli migration:generate --name <name>
Drizzlenpx drizzle-kit generate:migration --name <name>
Alembicalembic revision --autogenerate -m "<name>"

Apply / Status / Rollback — analogous commands per tool.

Step 3: If Creating — Help Write Migration

  1. Ask what schema changes are needed (or infer from context)
  2. For schema-based ORMs — edit schema first, then generate
  3. For code-based migrations — generate template and fill in up/down
  4. Review generated migration before applying

Step 4: Apply & Verify

  1. Show migration SQL preview if possible
  2. Apply migration
  3. Verify with status command

Rules

  • ALWAYS show migration content before applying in production
  • ALWAYS confirm before rollback operations
  • NEVER apply to production without explicit confirmation
  • For destructive operations (drop table, remove column), double-warn
  • If ORM can't be detected, ask the user