Skip to content
Latchkey

Prisma "prisma db push" schema sync fails in CI

prisma db push applies your schema.prisma directly to the database without creating migration files. In CI it fails when the schema is invalid, the database is unreachable, or a change would drop data and no accept-loss flag is set.

What this error means

A prisma db push step fails with a data-loss warning ("We need to reset the ... schema"), a validation error, or a connection error, and the schema is not applied.

Prisma
We need to reset the "public" schema at "localhost:5432"
Do you want to continue? All data will be lost.
Error: We could not reset the database in a non-interactive environment.

Common causes

A destructive change without acceptance

db push would drop a column or table; in a non-interactive CI it cannot prompt, so it aborts unless data loss is accepted.

An invalid schema or unreachable database

A schema validation error or a connection failure stops push before it can sync.

How to fix it

Accept data loss for ephemeral CI databases

On a disposable CI database it is safe to accept the reset so push can proceed non-interactively.

Terminal
npx prisma db push --accept-data-loss --skip-generate

Prefer migrate deploy for shared databases

Use committed migrations rather than db push where losing data is unacceptable.

Terminal
npx prisma migrate deploy

How to prevent it

  • Use db push only for prototyping or ephemeral CI databases.
  • Pass --accept-data-loss only when the database is disposable.
  • Use migrate deploy with committed migrations for persistent databases.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →