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.
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.
npx prisma db push --accept-data-loss --skip-generatePrefer migrate deploy for shared databases
Use committed migrations rather than db push where losing data is unacceptable.
npx prisma migrate deployHow to prevent it
- Use db push only for prototyping or ephemeral CI databases.
- Pass
--accept-data-lossonly when the database is disposable. - Use migrate deploy with committed migrations for persistent databases.