migrate

Update your database schema with migrations

The prisma migrate command group provides tools to create and apply database migrations.

Prisma Migrate does not apply to MongoDB. Use db push instead.

Usage

prisma migrate [command] [options]

Global options

OptionDescription
-h, --helpDisplay help message
--configCustom path to your Prisma config file
--schemaCustom path to your Prisma schema

Development commands

CommandDescription
prisma migrate devCreate a migration from schema changes, apply it, and trigger generators
prisma migrate resetReset your database and apply all migrations (all data will be lost)

Production/staging commands

CommandDescription
prisma migrate deployApply pending migrations to the database
prisma migrate statusCheck the status of your database migrations
prisma migrate resolveResolve issues with database migrations (baseline, failed migration, hotfix)

Commands for any stage

CommandDescription
prisma migrate diffCompare the database schema from two arbitrary sources

Examples

# Create and apply a migration in development
prisma migrate dev

# Reset the database (development only)
prisma migrate reset

# Apply pending migrations in production
prisma migrate deploy

# Check migration status
prisma migrate status

# Compare database schemas
prisma migrate diff \
  --from-config-datasource \
  --to-schema=./prisma/schema.prisma \
  --script

See also

On this page