prisma migrate reset drops the database or schema, recreates it and applies every migration: the data does not survive, by design. prisma db push --force-reset resets the database and then pushes the schema. A plain prisma db push that warns about data loss goes on only if the reset it offers is accepted or --accept-data-loss is passed. If one of these ran against production, the rows are no longer in the database: restore them from a point-in-time restore or a backup, to just before the command.
Recover now
- Stop the agent or the process. End the agent session, cancel any background task, and stop the test run, deploy job or service that ran the command, so nothing runs again against the database you are about to restore.
- Do not run
prisma migrate dev,db pushormigrate resetagain to "repair" it. After a reset the schema looks right and every table is empty: check row counts, not whether the tables exist. Write down when the command ran; every restore below needs that moment. - Restore to a point just before the command, into a separate instance. Self-managed PostgreSQL: restore the base backup and replay the archived WAL with
recovery_target_timeset just before it; apg_dumpfile restores only to when it was taken. Amazon RDS / Aurora: "Restore to point in time" creates a new DB instance (RDS) or cluster (Aurora) at any moment within the backup retention period, without modifying the source. Neon: instant restore takes a root branch back to a moment within its history window. Supabase: the daily backups and, where it is enabled, point-in-time recovery are under Database → Backups. Railway: volume backups, if they were created or scheduled, are restored from the service. MySQL: restore the last full backup, then replay the binary log withmysqlbinlogup to just before the destructive event. - Check the restored copy, then move it back. Compare row counts and the latest rows with what you expect, then point the application at the restored instance or copy the tables back (
pg_dump -t tablefrom the restored instance). Rows written between the restore point and now must be re-applied by hand. - No backup and no point-in-time recovery? Look for other copies: a staging or development database, a read replica, exports, a data warehouse, or the systems the data came from. One of the reports below recovered part of the data from a development copy and an auth provider export.
- After the restore, check the migration state with
prisma migrate status, which comparesprisma/migrationswith the_prisma_migrationstable, before you deploy again.
Why it happened
These are development commands that reached production. In both public reports, DATABASE_URL pointed at the production database. In one (#33183), the database had drifted from schema.prisma (custom SQL functions, manual changes), so prisma db push offered a reset, and it was accepted. In the other (#36183), db push stopped and asked for --accept-data-loss, and --force-reset was run instead. The Stack Overflow question people land on, "How to run Prisma schema update without erasing the PostgreSQL data?", has the same root: db push and migrate dev are for development, migrate deploy is for production.
What each Prisma command does (Prisma ORM 7 docs)
prisma migrate resetis marked "for use in development environments only". It drops the database or schema if possible (or performs a soft reset where dropping is not allowed), recreates it and applies all migrations.--forceskips the confirmation prompt. In Prisma ORM 7 it no longer runs seed scripts automatically; runprisma db seedexplicitly.prisma db pushpushes the state of the Prisma schema to the database without migrations; the docs present it for prototyping and local development. If it anticipates data loss, it throws an error and requires--accept-data-lossto go on.prisma db push --force-resetresets the database and then updates the schema.--accept-data-loss"ignores data loss warnings". It is narrower than a reset, but it is not a safe flag: it accepts losing the data the change touches.prisma migrate deployapplies pending migrations and is the command for non-development environments: it does not look for drift and does not reset.- The Prisma CLI detects popular AI coding agents (the docs list Claude Code, Gemini CLI, Qwen Code, Cursor, Aider and Replit) and blocks destructive actions such as
prisma migrate reset --forceuntil the user gives explicit consent, which the agent passes inPRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION.
Prisma ORM 8 renames several of these commands; check the docs for the version you run.
How to prevent it
Each of these commands ends in plain SQL on its connection: per the Prisma docs a reset drops the schema or the database, and a destructive push drops tables. When Prisma connects through the proxy, those statements are blocked before they reach the database and the command fails with an error instead of resetting production.
Vericto checks each SQL statement on its AST before it reaches the database. These are the rules that report the statements of this incident, with the real CLI output on each rule's example:
VERICTO-012: DROP SCHEMA
The rule's example · Critical
-- migrations/0043_drop_analytics.sql
DROP SCHEMA analytics CASCADE;
Real CLI output
$ npx @vericto/vericto-cli@2.3.0 check --offline migrations/0043_drop_analytics.sql
note: offline mode: 42 standard rules at default severities, engine 5.1.0. Custom rules, overrides, sensitive columns, allowlists and the audit trail apply online only.
✖ migrations/0043_drop_analytics.sql BLOCKED VERICTO-012 critical
DropStmt
fix: Use a versioned migration tool (Flyway, Prisma Migrate, Alembic, Rails migrations)
1 blocked · 0 allowed · 0 flagged · 0 monitored (ruleset standard@engine-5.1.0 · mode: offline (engine 5.1.0, 42 standard rules, no workspace policy))
✖ Vericto blocked 1 statement (ruleset standard@engine-5.1.0 · mode: offline (engine 5.1.0, 42 standard rules, no workspace policy))
✖ migrations/0043_drop_analytics.sql BLOCKED VERICTO-012 critical
DropStmt
fix: Use a versioned migration tool (Flyway, Prisma Migrate, Alembic, Rails migrations)
This is Vericto enforcing a rule — the exit code is intentional, not a crash.
To allow a finding on purpose, add an inline comment on the statement:
-- vericto:ignore[VERICTO-012] <reason> (a reason is required)
The CLI blocks it and exits with code 1, so the CI job fails before the merge.
VERICTO-010: DROP TABLE or DROP DATABASE
The rule's example · Critical
-- migrations/0042_drop_users.sql
DROP TABLE users;
Real CLI output
$ npx @vericto/vericto-cli@2.3.0 check --offline migrations/0042_drop_users.sql
note: offline mode: 42 standard rules at default severities, engine 5.1.0. Custom rules, overrides, sensitive columns, allowlists and the audit trail apply online only.
! migrations/0042_drop_users.sql FLAGGED VERICTO-010 critical
DropStmt
fix: Use a versioned migration tool (Flyway, Prisma Migrate, Alembic, Rails migrations)
0 blocked · 0 allowed · 1 flagged · 0 monitored (ruleset standard@engine-5.1.0 · mode: offline (engine 5.1.0, 42 standard rules, no workspace policy))
In a migration file the CLI marks it FLAGGED and exits with 0: a schema change in a migration is usually intended, so it is raised for review instead of blocked. With --fail-on flag (or fail_on = "flag" in .vericto.toml) it exits with 1 and the job fails. Outside a migration (--sql, stdin or another file) it blocks, as the proxy and MCP check_sql do.
Set up the agent so it goes through Vericto
- Connect the agent to the database through the proxy. Its connection URL points at the Vericto TCP proxy, not at the database. The proxy checks each statement, including the ones an ORM command run by the agent sends, and at runtime it blocks
DROP,TRUNCATEandALTER … DROP COLUMNbefore they reach the database. For a coding agent,vericto-proxy mcpgives itexecute_sql,describe_schemaandcheck_sql, never the database credential. - Keep the direct production credential away from the agent. Not in the
.env, the shell or the environment the agent and its test runs load. If the agent has another way to the database, the proxy does not see it. - Give it a read-only role through Vericto. The role behind
vericto-proxy mcpis read-only (the SQL to create it is in the MCP docs), and agent access sets each agent to read-only on the tables you choose. - Let the agent check SQL before it runs it with the MCP
check_sqltool: it gets the verdict, the rule and the suggested fix.
In CI, on the migration files
For db push and migrate reset, none of these commands writes a SQL file, so CI has nothing to check; the proxy is the layer that sees them. Your migrations are files: the migration.sql files under prisma/migrations/, or the output of prisma migrate diff --script, are .sql files the Action checks in the pull request.
The vericto/check-sql GitHub Action (Apache-2.0) runs the same offline check on the .sql files a PR changes. Save it as .github/workflows/vericto.yml:
on: pull_request
jobs:
vericto:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with: { fetch-depth: 0 }
- uses: vericto/check-sql@v1
with: { offline: true, upload-sarif: false }
Or try the CLI on your machine, with no account (AGPL-3.0-only):
npx @vericto/vericto-cli@2.3.0 check --offline migrations/
Scope: Vericto protects the connections that go through Vericto. A shell on the database host, or a credential that connects directly, bypasses it.
Frequently asked questions
Sources
The public reports this page cites, checked on 2026-11-14, and the official docs behind each fact about the tools:
- anthropics/claude-code#33183 (March 11, 2026): a developer reports prisma db push against production, where Prisma detected drift, offered a reset and the reset was accepted
- anthropics/claude-code#36183 (March 19, 2026): a developer reports prisma db push --force-reset run on a production database
- Prisma docs: Prisma CLI reference (Prisma ORM 7): migrate reset, db push, migrate deploy and the AI agent guard
- Prisma docs: prototyping your schema with db push
- PostgreSQL docs: continuous archiving and point-in-time recovery
- Amazon RDS docs: restoring a DB instance to a specified time
- Neon docs: instant restore (point-in-time restore of a root branch)
- Supabase docs: database backups and point-in-time recovery
- Railway docs: volume backups
Related pages
- Claude Code deleted your production database or dropped a column? How to recover
- drizzle-kit push --force deleted your data? How to recover, and push vs migrate
- AI agent deleted your production database? What happened and how to recover
- VERICTO-012: DROP SCHEMA
- VERICTO-010: DROP TABLE or DROP DATABASE
- When an AI agent runs destructive SQL on production