BACK TO DIRECTORY
commandintermediate
/migrate
Manages database schema migrations for Prisma, Drizzle, or raw SQL projects. Can generate new migrations from schema changes, run pending migrations, rollback the last migration, check migration status, and seed the database. Includes safety checks for production environments and generates migration names from the schema diff.
389 STARS
5.1k DOWNLOADS
claude-templates
databasemigrationsprismadrizzleschema
CONFIGURATION
markdown
1# /migrate Command23## Description4Manage database schema migrations.56## Commands78### Generate Migration9Create a new migration from schema changes:10```bash11# Prisma12npx prisma migrate dev --name add_user_roles1314# Drizzle15npx drizzle-kit generate --name add_user_roles16```1718### Run Migrations19Apply pending migrations:20```bash21# Development22npx prisma migrate dev2324# Production25npx prisma migrate deploy26```2728### Check Status29View migration history:30```bash31npx prisma migrate status32```3334### Reset Database35Reset and re-run all migrations (DEVELOPMENT ONLY):36```bash37npx prisma migrate reset --force38```3940### Seed Database41Populate with test data:42```bash43npx prisma db seed44```4546## Safety Checks47Before running migrations in production:481. Verify backup exists492. Check for destructive changes (DROP TABLE, DROP COLUMN)503. Estimate migration duration for large tables514. Plan for zero-downtime (add column, then backfill, then add constraint)5253## Best Practices54- Never edit a migration after it has been applied55- One logical change per migration56- Test migrations on a copy of production data57- Include both up and down migrations58- Name migrations descriptively (add_user_email_index)5960## Usage61- `/migrate` - Run pending migrations62- `/migrate new` - Generate new migration63- `/migrate status` - Check migration state64- `/migrate reset` - Reset database (dev only)