Prisma "db push" Aborts with Data-Loss Warning in CI
prisma db push syncs the schema directly to the database. When the change would drop a column or table, Prisma warns about data loss and, in a non-interactive CI shell, refuses rather than prompting. This is a safety stop, not a flaky failure.
What this error means
prisma db push in CI exits non-zero reporting potential data loss and that it cannot prompt for confirmation. It is deterministic - the same schema delta is destructive every run.
⚠️ There might be data loss when applying the changes:
• You are about to drop the column `legacy_code` on the `orders` table.
Use the --accept-data-loss flag to ignore the warning.
Error: Migration cancelled.Common causes
Destructive schema delta
The schema removes or retypes a column/table, so applying it would drop data. Prisma blocks to avoid silently destroying it.
db push used where migrations belong
db push is for prototyping. Using it against a real/CI database for destructive changes bypasses reviewable migration history.
Non-interactive shell cannot confirm
In CI there is no TTY to answer the prompt, so the command aborts instead of waiting for input.
How to fix it
Switch to migrations for real changes
Generate a reviewed migration and apply it with deploy, instead of pushing the schema directly.
npx prisma migrate dev --name drop_legacy_code # locally, creates migration
npx prisma migrate deploy # in CIAccept data loss only for throwaway databases
For an ephemeral prototype database where losing data is fine, pass the flag explicitly.
npx prisma db push --accept-data-lossHow to prevent it
- Use
migrate dev/migrate deployfor any database whose data matters. - Reserve
db pushfor disposable prototype databases. - Stage destructive changes (deprecate, backfill, then drop) through migrations.