Develop schema changes
You changed models in the Prisma schema and need corresponding SQL migration files applied locally.
Prisma · Command
prisma migrate dev creates and applies migrations while developing. It uses a shadow database to detect drift and requires a development environment.
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.
prisma migrate dev [options]| Name | Type | Description |
|---|---|---|
--url | option | Override the datasource URL from the Prisma config file. |
--config | option | Custom path to a Prisma config file. |
--schema | option | Custom path to the Prisma schema. |
--name, -n | option | Name the migration; -n is the short form. |
--create-only | option | Create a migration without applying it. |
--help, -h | option | Display help information; -h is the short form. |
Creates migration files and applies applicable migrations; the command reports migration status and updates the _prisma_migrations table.
prisma.config.ts.npx prisma migrate dev --name add-profile --create-onlyCreates a named migration from schema changes without applying it; review the generated SQL before applying it in development.
You changed models in the Prisma schema and need corresponding SQL migration files applied locally.
You need to inspect or edit generated SQL before applying it.
You want to validate migration history and detect drift against a development database.
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.
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.
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 migrateprisma migrate deployprisma migrate resetprisma db pushshadow databasePrisma schema