Prisma "migrate dev" prompts and fails in CI (use migrate deploy)
prisma migrate dev is a development command: it can generate new migrations, prompt, and reset the database. In CI you want migrate deploy, which only applies existing migrations non-interactively.
What this error means
A CI step using prisma migrate dev hangs on a prompt, errors that it cannot run interactively, or unexpectedly resets data.
Prisma
Prisma Migrate has detected that the environment is non-interactive. It is recommended to use `prisma migrate deploy` in CI/CD environments.
Error: This command is not supported in a non-interactive environment.Common causes
migrate dev used in a pipeline
migrate dev expects a developer at a prompt and may create or reset migrations, which is wrong for CI.
Expecting dev-style behavior in deploy
Teams sometimes reach for migrate dev to also generate migrations in CI, which it should not do in a pipeline.
How to fix it
Use migrate deploy in CI
Apply committed migrations only, without prompts or resets.
.github/workflows/ci.yml
- run: npx prisma migrate deployGenerate migrations locally, apply in CI
- Run
prisma migrate devlocally to author and commit migrations. - Commit the generated migration folders.
- Let CI run only
prisma migrate deploy.
Terminal
# local
npx prisma migrate dev --name add_users
# CI applies committed migrations
npx prisma migrate deployHow to prevent it
- Reserve migrate dev for local development only.
- Use migrate deploy in every CI/CD pipeline.
- Commit migration folders so deploy has them to apply.
Related guides
Prisma "P3009: migrate found failed migrations in the target database" in CIFix Prisma "P3009: migrate found failed migrations in the target database" in CI - a prior migration is marke…
Prisma "P3005: The database schema is not empty" (baseline) in CIFix Prisma "P3005: The database schema is not empty" in CI - migrate deploy hit an existing schema with no mi…
Prisma "Drift detected: your database schema is not in sync" in CIFix Prisma "Drift detected: Your database schema is not in sync with your migration history" in CI - the data…