Skip to content
Latchkey

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.

prisma output
⚠️  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.

Terminal
npx prisma migrate dev --name drop_legacy_code   # locally, creates migration
npx prisma migrate deploy                        # in CI

Accept data loss only for throwaway databases

For an ephemeral prototype database where losing data is fine, pass the flag explicitly.

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

How to prevent it

  • Use migrate dev/migrate deploy for any database whose data matters.
  • Reserve db push for disposable prototype databases.
  • Stage destructive changes (deprecate, backfill, then drop) through migrations.

Frequently asked questions

What causes ""data loss" on db push"?
The schema removes or retypes a column/table, so applying it would drop data. Prisma blocks to avoid silently destroying it.
How do I fix "data loss" on db push?
Generate a reviewed migration and apply it with deploy, instead of pushing the schema directly.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card