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.
Usage
prisma migrate dev [options]The datasource URL configuration is read from the Prisma config file (e.g., prisma.config.ts).
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
Prisma v7: migrate dev no longer automatically triggers prisma generate or seed scripts. Run them explicitly if needed.
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 |
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 devName the migration
npx prisma migrate dev --name added_job_titleCreate migration without applying
npx 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
npx prisma migrate dev --schema=./alternative/schema.prisma