prisma migrate deploy: Apply Migrations in CI
prisma migrate deploy applies all pending migrations from the migrations folder without prompting, which is why it is the CI and production command.
Prisma has two migration commands: migrate dev for local development (it can generate and reset) and migrate deploy for CI and production, which only applies existing migrations.
What it does
prisma migrate deploy applies every migration in prisma/migrations that is not yet recorded in the _prisma_migrations table, in order, and never generates new migrations or resets the database. It is fully non-interactive.
Common usage
# CI: apply migrations before the app deploys
npx prisma migrate deploy
# DATABASE_URL comes from the environment / schema.prisma datasource
DATABASE_URL="$DATABASE_URL" npx prisma migrate deployOptions
| Command / flag | What it does |
|---|---|
| migrate deploy | Apply pending migrations, non-interactive (use in CI) |
| migrate dev | Dev-only: generate + apply + can reset (never in CI) |
| --schema <path> | Path to schema.prisma if not the default |
| migrate status | Report which migrations are applied or pending |
In CI
Always use migrate deploy in pipelines, never migrate dev, because dev is interactive and may reset the database (dropping data) if it detects drift. Run deploy as a step before the app rolls out. Prisma records state in _prisma_migrations and does not hold a long lock, so keep migration jobs from overlapping.
Common errors in CI
"P3009: migrate found failed migrations in the target database" means a prior migration is recorded as failed and deploy refuses to continue; resolve it (fix the schema and mark it applied or rolled back with prisma migrate resolve). "P3005: The database schema is not empty" appears when deploying into an existing database with no migration history; baseline it. "P1001: Can't reach database server" means the URL or network is wrong.