Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Prisma · Command

prisma migrate dev

prisma migrate dev creates and applies migrations while developing. It uses a shadow database to detect drift and requires a development environment.

How it works

Run this development-only command after changing the Prisma schema. Prisma checks migration history in a shadow database, detects drift, creates a migration for schema changes, and applies unapplied migrations to the development database while updating migration state.

Syntax

prisma migrate dev [options]

Parameters

NameTypeDescription
--urloptionOverride the datasource URL from the Prisma config file.
--configoptionCustom path to a Prisma config file.
--schemaoptionCustom path to the Prisma schema.
--name, -noptionName the migration; -n is the short form.
--create-onlyoptionCreate a migration without applying it.
--help, -hoptionDisplay help information; -h is the short form.

Returns

Creates migration files and applies applicable migrations; the command reports migration status and updates the _prisma_migrations table.

Key points

  • It both generates migrations from Prisma schema changes and applies them during development.
  • Prisma replays existing migrations in a shadow database to identify drift.
  • Pending migrations are applied to the shadow database before new changes are evaluated.
  • Schema edits can produce a new migration during the command run.
  • Unapplied migrations reach the development database, and Prisma records their status.
  • The datasource connection is read from Prisma configuration, such as prisma.config.ts.

Common mistakes

  • Do not use this command in production.
  • A shadow database is required for checking migration history and detecting schema drift.
  • MongoDB is not a supported datasource for this command.

Example: Create a migration for review

npx prisma migrate dev --name add-profile --create-only

Creates a named migration from schema changes without applying it; review the generated SQL before applying it in development.

When to use it

Develop schema changes

You changed models in the Prisma schema and need corresponding SQL migration files applied locally.

Prepare a migration without applying

You need to inspect or edit generated SQL before applying it.

Check migration consistency

You want to validate migration history and detect drift against a development database.

Interview questions

QWhat does prisma migrate dev do?

It replays migration history in the shadow database to detect drift, applies pending migrations there, generates a migration for Prisma schema changes, and applies unapplied migrations to the development database. It also updates the _prisma_migrations table.

Follow-up: Why use a shadow database? It provides a separate environment where Prisma can replay migration history and compare the resulting schema with the expected state without modifying the development database.

QHow can you create a migration without applying it?

Use --create-only to generate a migration without applying it. This is useful when the SQL needs review or manual editing before application.

Follow-up: How would you supply a migration name? Add --name, or its short form -n, followed by the name, such as --name add-profile.

QWhy should this command not be used in production?

It is intended for development environments and requires a shadow database. Production deployments should use a production migration workflow rather than this command.

Follow-up: What can cause a reset prompt? Schema drift or a migration-history conflict can cause Prisma to request a database reset to synchronize state.

  • prisma migrate
  • prisma migrate deploy
  • prisma migrate reset
  • prisma db push
  • shadow database
  • Prisma schema

Source: prisma migrate dev | Create & Apply Migrations. Checked 2026-10-16.