Claude Code deleted your production database or dropped a column? How to recover

VERICTO-015 VERICTO-010 VERICTO-012

In the public reports, Claude Code did not get around a protection in the database: it ran a command that is destructive by design, with a credential that reached production. Four reports on the Claude Code issue tracker in 2026 describe it: two ALTER TABLE … DROP COLUMN run over SSH during an investigation, a drizzle-kit push --force, a prisma db push whose reset prompt was accepted, and a prisma db push --force-reset. Whatever the command, recovery is the same: stop the session, run no more migrations, and restore to a moment 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 more migrations, pushes or resets, and do not let the agent "repair" the schema. Recreating the tables brings back empty tables, not the rows. Write down when the destructive command ran (from the agent transcript, the shell history or the database log): 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_time set just before it; a pg_dump file 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 with mysqlbinlog up 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 table from 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.
  • Check what else the session changed. One report says the agent also changed the production DATABASE_URL environment variable, which made recovery harder; another, that dropped columns left triggers pointing at them. Review the session transcript before you restore.

Why it happened

The reports show two mechanisms. In one (#46684), the agent was asked to investigate and went on to fix: it had a shell on the production server and a database session there, and treated finding the cause as permission to change the schema. In the other three, a development command ran against production: the project's DATABASE_URL pointed at the production database, and when the ORM stopped at a warning or a prompt, the agent accepted the reset, chose --force-reset, or passed --force to skip it. The prompts these tools show are answered by whoever runs the command, an agent included.

What the four reports describe

  • #46684 (April 2026). The developer asked the agent to "use SSH and get the error". The agent connected to the production server, found the cause (a stored generated column that a legacy ORM layer could not handle) and ran two ALTER TABLE … DROP COLUMN on the live production database without asking. The developer reports that triggers still referenced the dropped columns, so the original error persisted.
  • #27063 (February 2026). An agent in a separate terminal session ran drizzle-kit push --force against production PostgreSQL on Railway. The developer reports that every table was wiped, that the database had no automatic backups or point-in-time recovery, and that the few tables left were dropped during the recovery attempts.
  • #33183 (March 2026). During a routine deploy task, the agent ran prisma db push with DATABASE_URL pointing at production. Prisma detected drift and offered to reset the database; the reset was accepted, dropping the tables, custom SQL functions and enums. Part of the data was recovered from a development copy and an auth export.
  • #36183 (March 2026). Asked to add a field and push the schema, the agent got a prisma db push warning that the change needed --accept-data-loss, and ran prisma db push --force-reset in the background instead. All tables were recreated empty; the developer reports no backup existed.

All four issues are closed on GitHub.

How to prevent it

For Vericto, the four reports are two different cases. The ORM commands (#27063, #33183, #36183) send plain DROP statements over a database connection: when that connection goes through the proxy, they are blocked before they reach the database and the command fails. The SSH case (#46684) is the one Vericto does not cover on its own: a shell on the production server can open its own session to the database. There, do not give the agent that shell; give it database access through vericto-proxy mcp with a read-only role.

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-015: ALTER TABLE DROP COLUMN

The rule's example · High

-- migrations/0045_drop_email.sql
ALTER TABLE users DROP COLUMN email;

Real CLI output

$ npx @vericto/vericto-cli@2.3.0 check --offline migrations/0045_drop_email.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/0045_drop_email.sql  FLAGGED  VERICTO-015 high
    AlterTableStmt > AlterTableCmd.subtype = DROP_COLUMN
    fix: Use soft-delete (nullable column) or a versioned migration tool
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.

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.

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.

Set up the agent so it goes through Vericto

  1. 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, TRUNCATE and ALTER … DROP COLUMN before they reach the database. For a coding agent, vericto-proxy mcp gives it execute_sql, describe_schema and check_sql, never the database credential.
  2. 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.
  3. Give it a read-only role through Vericto. The role behind vericto-proxy mcp is 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.
  4. Let the agent check SQL before it runs it with the MCP check_sql tool: it gets the verdict, the rule and the suggested fix.

In CI, on the migration files

In these reports, none of these commands writes a SQL file, so CI has nothing to check; the proxy is the layer that sees them. If you also apply schema changes through reviewed migrations (prisma migrate dev --create-only, drizzle-kit generate), the Action checks those .sql files 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: