Database Migrations in Prisma

From the Prisma ORM cheat sheet · Prisma Migrations & Database Management · verified Nov 2026

Database Migrations

Version control your database schema changes with Prisma Migrate

bash
# Create a new migration
npx prisma migrate dev --name add_user_table

# Apply migrations in production
npx prisma migrate deploy

# Create migration without applying (preview)
npx prisma migrate dev --create-only

# Reset database (removes all data!)
npx prisma migrate reset

# Check migration status
npx prisma migrate status

# Resolve failed migrations
npx prisma migrate resolve --applied "20231201123456_migration_name"
bash
# Development workflow
npx prisma migrate dev     # Create and apply migration
npx prisma generate        # Regenerate Prisma Client (no longer automatic in Prisma 7)
npx prisma studio          # Open GUI to view/edit data

# Production deployment
npx prisma migrate deploy  # Apply pending migrations
npx prisma generate        # Generate Prisma Client

# Migration management: SQL to bring the database (from prisma.config.ts) to the schema
npx prisma migrate diff \
  --from-config-datasource \
  --to-schema prisma/schema.prisma \
  --script > migration.sql
💡 Always review migration SQL before applying
⚠️ Don't edit migration files after applying
📌 Use --create-only to preview migrations
✅ Reset dev DB with npx prisma migrate reset, then run npx prisma db seed (reset no longer seeds)

Continue with Prisma ORM

Save the full cheat sheet or work through every related task.

More Prisma tasks

Back to the full Prisma ORM cheat sheet