dev

Create a migration from changes in Prisma schema, apply it to the database, and trigger generators

The prisma migrate dev command creates and applies migrations during development. It requires a shadow database.

For use in development environments only.

This command is not supported on MongoDB. Use db push instead.

Usage

prisma migrate dev [options]

The datasource URL configuration is read from the Prisma config file (e.g., prisma.config.ts).

How it works

  1. Reruns the existing migration history in the shadow database to detect schema drift
  2. Applies pending migrations to the shadow database
  3. Generates a new migration from any changes you made to the Prisma schema
  4. Applies all unapplied migrations to the development database and updates the _prisma_migrations table

Prisma v7: migrate dev no longer automatically triggers prisma generate or seed scripts. Run them explicitly if needed.

Options

OptionDescription
-h, --helpDisplay help message
--configCustom path to your Prisma config file
--schemaCustom path to your Prisma schema
--urlOverride the datasource URL from the Prisma config file
-n, --nameName the migration
--create-onlyCreate a new migration but do not apply it

If a schema drift is detected while running with --create-only, you will be prompted to reset your database.

Examples

Create and apply migrations

npx prisma migrate dev

Name the migration

npx prisma migrate dev --name added_job_title

Create migration without applying

npx prisma migrate dev --create-only

This creates the migration file but doesn't apply it. Run prisma migrate dev again to apply.

Specify a schema path

npx prisma migrate dev --schema=./alternative/schema.prisma

See also

On this page