Back to Prisma

dev

apps/docs/content/docs/cli/migrate/dev.mdx

latest2.4 KB
Original Source

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

For use in development environments only.

:::warning

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

:::

Usage

bash
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

:::info

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

:::info

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

:::

Examples

Create and apply migrations

npm
npx prisma migrate dev

Name the migration

npm
npx prisma migrate dev --name added_job_title

Create migration without applying

npm
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

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

See also