dev (Prisma CLI v7)
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.
prisma migrate dev [options]The datasource URL configuration is read from the Prisma config file (e.g., prisma.config.ts).
How it works
Section titled “How it works”- Reruns the existing migration history in the shadow database to detect schema drift
- Applies pending migrations to the shadow database
- Generates a new migration from any changes you made to the Prisma schema
- Applies all unapplied migrations to the development database and updates the
_prisma_migrationstable
Options
Section titled “Options”| Option | Description |
|---|---|
-h, --help |
Display help message |
--config |
Custom path to your Prisma config file |
--schema |
Custom path to your Prisma schema |
--url |
Override the datasource URL from the Prisma config file |
-n, --name |
Name the migration |
--create-only |
Create a new migration but do not apply it |
Examples
Section titled “Examples”Create and apply migrations
Section titled “Create and apply migrations”bunx prisma migrate devpnpm prisma migrate devyarn prisma migrate devnpx prisma migrate devName the migration
Section titled “Name the migration”bunx prisma migrate dev --name added_job_titlepnpm prisma migrate dev --name added_job_titleyarn prisma migrate dev --name added_job_titlenpx prisma migrate dev --name added_job_titleCreate migration without applying
Section titled “Create migration without applying”bunx prisma migrate dev --create-onlypnpm prisma migrate dev --create-onlyyarn prisma migrate dev --create-onlynpx prisma migrate dev --create-onlyThis creates the migration file but doesn't apply it. Run prisma migrate dev again to apply.
Specify a schema path
Section titled “Specify a schema path”bunx prisma migrate dev --schema=./alternative/schema.prismapnpm prisma migrate dev --schema=./alternative/schema.prismayarn prisma migrate dev --schema=./alternative/schema.prismanpx prisma migrate dev --schema=./alternative/schema.prisma