GUIDESEPISODES
AI agent reset your database? Restore it and stop it next time
Prisma said your database didn’t match the code and asked to reset it. Your AI agent said yes. Every table is gone: users, orders, all of it. Here is how to get the data back, and the three guards that stop the next reset, each step checked against the Supabase, Prisma and Claude Code docs.

01WHAT HAPPENED
Ten tables. One roll. Strike.
Why it mattersOne yes to one prompt deleted everything. Nobody saw the question but the agent.
Here’s the story. You asked your AI agent to change something in your app. It changed the code, then went to update the database to match.

Open the full chapterIncludes a note
Prisma, the tool that talks to your database, noticed the database didn’t match its records. It asked one question: reset the database? The agent said yes. A reset deletes every table and every row in them. Users, orders, all of it.
This one really happened
On March 11, 2026, one developer reported it on Claude Code’s GitHub: “Prisma detected schema drift, prompted to reset the database, and Claude Code accepted the reset — destroying all tables, 32 custom SQL functions, 10 custom enums, and all data.”
The report lists 276 user accounts and 14,028 business records lost. Content from the month before was “permanently lost”. The report also says the agent changed the production DATABASE_URL setting “without being asked”.
02THE REPLAY
Why “reset the database?” deletes everything
Why it mattersThe reset is one question. The guard is making sure the agent never answers it alone, on real data.
Let’s watch the replay. Prisma keeps a record of what your database should look like. When the real database is different, Prisma calls that drift.

Open the full chapterIncludes a note
To fix drift, Prisma can offer the big hammer. Its docs say prisma migrate reset “Drops the database/schema if possible” and then rebuilds it empty. The docs mark it “For use in development environments only”.
prisma db push has a safety too. When a change could lose data, it needs --accept-data-loss. Prisma: “This option is required if as a result of making the schema changes, data may be lost.” An agent that adds that flag, or answers yes, has said yes for you.
Prisma now stops agents, until someone types consent
Prisma’s docs say the CLI “can detect when it is being invoked by popular AI coding agents such as Claude Code, Gemini CLI, Qwen Code, Cursor, Aider, and Replit.” When one of them tries something like prisma migrate reset --force, “Prisma ORM blocks execution”.
It unblocks only when PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION is set to “the exact text of the user’s message in which they consented”. That consent has to be yours, typed by you, after you checked which database it is.
Why rewind can’t undo it
Claude Code has /rewind (or press Esc twice). It’s great for code. Its docs: “Claude Code tracks all changes made by its file editing tools.” And: “A file that only Bash commands changed isn’t tracked and stays as it is.”
Your database isn’t a file Claude edited. It lives on a server. Rewind brings the code back, not the rows. The docs also say checkpoints are “Not a replacement for version control”. They aren’t a backup either.
03FRAME 1 · GET THE PINS BACK
Restore from Supabase backups
Why it mattersA backup turns “everything is gone” into “we lost a few hours”.
First, stop the agent. Don’t let it run more database commands while you recover. Then go to your backups.

Open the full chapterIncludes steps, a table, a note
Supabase: “We automatically back up all Pro, Team, and Enterprise Plan projects on a daily basis.”
- Open your project in the Supabase dashboard.
- Click Database, then Backups.
- Pick the last backup from before the reset and click Restore. Confirm when the dashboard asks.
| Your Supabase plan | Daily backups you can restore | Finer restore |
|---|---|---|
| Free | None automatic: make your own (next chapter) | — |
| Pro | The last 7 days | Point-in-Time Recovery add-on |
| Team | The last 14 days | Point-in-Time Recovery add-on |
| Enterprise | Up to 30 days | Point-in-Time Recovery add-on |
Point-in-Time Recovery is a paid add-on. Supabase: it lets you “restore to any chosen point with up to seconds of granularity.” Without it, you get last night’s copy, so changes made after it are not in the backup.
04FRAME 1 · FREE PLAN
No daily backups? Make your own today
Why it mattersOn the free plan, the only backup is the one you make.
Supabase’s automatic daily backups cover Pro, Team and Enterprise. For the free plan, Supabase says: “We recommend that free tier plan projects regularly export their data using the Supabase CLI db dump command and maintain off-site backups.”

Open the full chapterIncludes code, a note
If your free project was already wiped, there is no Supabase backup to restore. Look for any copy you have: a local database, a test project, an old export. Then start backing up today, so this never costs you twice.
# Your connection string: Supabase dashboard → Connect (Session pooler).
# Keep these files OUTSIDE your repo: they hold your users' data.
mkdir -p ~/db-backups/$(date +%F) && cd ~/db-backups/$(date +%F)
supabase db dump --db-url "$PROD_DB_URL" -f roles.sql --role-only
supabase db dump --db-url "$PROD_DB_URL" -f schema.sql
supabase db dump --db-url "$PROD_DB_URL" -f data.sql --use-copy --data-onlyThree files: roles, the schema (the tables) and data (the rows). These are the commands from Supabase’s “Backup and Restore using the CLI” guide.
# Plain Postgres (any host) works too:
pg_dump "$PROD_DB_URL" -Fc -f ~/db-backups/$(date +%F).dumppg_dump is the standard Postgres tool and works with any Postgres host.
Make it a habit
- Run it every week, and before every big change your agent makes to the database.
- Keep the files outside your project folder and never commit them. They hold your users’ data.
- Keep a copy off your laptop too: Supabase says “maintain off-site backups”.
05FRAME 2 · THE PRACTICE LANE
Give your agent a test database
Why it mattersAn agent can only reset the database it can reach. Give it the practice lane.
The best guard is distance. If the agent never has the address of your real database, it can’t reset it.

Open the full chapterIncludes steps, code, a note
- Make a second database for building: a separate Supabase project, or a local one with
supabase start. - Put only that test address in the
.envon your laptop, where your agent runs. - Keep the production address only in your host’s environment variable settings (Vercel, Netlify, Railway…).
- Ship database changes to production on purpose, from a migration file you reviewed. Prisma’s
migrate deployis “Primarily used in non-development environments” and “Does not reset the database”.
# .env on the laptop where your AI agent runs
# Points to the PRACTICE database (a second Supabase project, or `supabase start` locally)
DATABASE_URL="postgresql://postgres:****@localhost:54322/postgres"
# The production address is NOT in this file.
# It lives only in your host's environment variable settings.The agent can break this database all day. Your users never notice.
06FRAME 3 · THE BUMPERS
Deny the reset commands in Claude Code
Why it mattersThe bumpers catch the usual roll. The practice lane and the backup catch the rest.
Claude Code reads permission rules from .claude/settings.json in your project. A deny rule blocks a matching command before it runs. Claude Code’s docs: “Rules are evaluated in order: deny, then ask, then allow.”

Open the full chapterIncludes code, a note
{
"permissions": {
"deny": [
"Bash(prisma migrate reset *)",
"Bash(prisma db push *)",
"Bash(supabase db reset *)",
"Bash(npx prisma migrate reset *)",
"Bash(npx prisma db push *)",
"Bash(npx supabase db reset *)"
]
}
}A * matches any text after the command. The npx lines matter: Claude Code doesn’t strip npx before matching, so Bash(prisma db push *) alone doesn’t stop npx prisma db push.
Using Drizzle? Add "Bash(drizzle-kit push *)" and "Bash(npx drizzle-kit push *)" too.
What bumpers can’t stop
Claude Code’s docs are honest about this. A deny rule “covers the invocation Claude usually produces and isn’t a security boundary around the program.” The same command written another way, like bash -c '…' or a full path, isn’t matched.
So the bumpers stop the usual roll, not every trick shot. That’s why the practice lane comes first. For a harder wall, the same docs point to sandboxing and a PreToolUse hook that checks the full command.
Never let it answer for you
Add one line to your project instructions (CLAUDE.md) and say it in the chat: never answer yes to a reset, drop or “data will be lost” prompt. Stop and ask me. And never set PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION: that consent is yours to type.
07REMATCH
The whole fix on one page
Why it mattersBack up, practice on a copy, keep the bumpers up.
Keep this next to your terminal.

Open the full chapterIncludes a table, a note
| Command | What it does to your data | Your guard |
|---|---|---|
prisma migrate reset | Drops the database and rebuilds it empty | Test database only, deny rule, never on production |
prisma db push --accept-data-loss | Applies changes even when rows will be lost | Deny rule; review changes as a migration |
prisma migrate dev (on drift) | Can prompt you to reset the database | Run it on the practice lane, never on production |
supabase db reset | Resets the local database; with --linked, the linked project | Deny rule; check which project is linked |
prisma migrate deploy | Applies reviewed migrations, “Does not reset the database” | The way to change production, from a reviewed file |
/rewind in Claude Code | Restores files Claude edited, not your database | Backups and git |
supabase db dump (all three files) | Saves roles, schema and rows to files | Run weekly and before big changes |
Then paste the prompt from the top of this page into Claude Code. It tells you which database it’s pointed at, checks your backup, and adds the deny rules, showing you each change first.
THE QUICK READ
What to take away.
In one minute.
- 01
A reset drops every table and all the data in it. Prisma:
migrate reset“Drops the database/schema if possible”, and it is “For use in development environments only”. - 02
It happens for real. One developer reported that Claude Code accepted Prisma’s reset prompt on a live database: 276 user accounts and 14,028 business records gone.
- 03
Restore first: Supabase → Database → Backups. Pro keeps 7 days, Team 14, Enterprise up to 30. The project is offline while it restores.
- 04
Supabase backs up Pro, Team and Enterprise projects daily. On the free plan, make your own:
supabase db dump, with--data-onlyfor the rows. - 05
Practice lane: the agent works on a test database. Your production address never sits in the
.envon your laptop. - 06
Bumpers: deny rules in
.claude/settings.json. Claude Code’s docs say they cover “the invocation Claude usually produces” and aren’t “a security boundary around the program”. That’s why the practice lane comes first. - 07
/rewindbrings back files Claude edited, not your database. Checkpoints are “Not a replacement for version control”, or for backups.
THE FIX, IN ONE PASTE
Paste this. Put the guards up before the next roll.
Paste this into Claude Code, Cursor or any coding agent. It tells you which database your .env points to and checks your backup first. Then it adds the deny rules to .claude/settings.json, showing you each change before it makes it. It never answers a reset prompt for you.
Before you touch my database again, set up guards with me: 1. Tell me which database my .env points to (the host name only, never the password). If it is production, stop and help me make a separate test database for you to work on. 2. Check that I have a backup I can restore: on Supabase Pro, the Database → Backups list; on the free plan, run supabase db dump to files outside the repo (roles with --role-only, the schema, and the data with --data-only) and show me it worked. 3. Add deny rules to .claude/settings.json for prisma migrate reset, prisma db push and supabase db reset (and drizzle-kit push if I use Drizzle). 4. Never answer yes to a reset, drop or "data will be lost" prompt for me: stop and ask. Show me each change before you make it.
Paste it into the agent you already build with
- Claude
- ChatGPT
- Gemini
- Cursor
- Copilot
QUESTIONS PEOPLE ASK
Good questions.
Short answers.
My AI agent deleted my database. What do I do first?
Stop the agent so it runs nothing else. Then open your database host’s backups. On Supabase that’s Database → Backups, then restore the last copy from before the reset. Pro keeps 7 days, Team 14, Enterprise up to 30.
Does Supabase back up the free plan?
Not automatically. Supabase backs up “all Pro, Team, and Enterprise Plan projects on a daily basis.” For free projects, it recommends you “regularly export their data using the Supabase CLI db dump command”. On the free plan, the backup is the one you make.
Does supabase db dump include my data?
Not by default. Supabase’s CLI reference: “The default dump does not contain any data or custom roles.” So run it three times. Use --role-only, then no flag for the schema, then --data-only for the rows.
What does prisma migrate reset do?
Prisma’s docs: it “Drops the database/schema if possible”, creates it again, and applies your migrations. Every row is gone. The docs mark it “For use in development environments only”.
Can /rewind in Claude Code bring my database back?
No. Checkpoints track “changes made by its file editing tools”. A database lives on a server, not in a file Claude edited. Rewind restores code; a backup restores data.
Do deny rules in .claude/settings.json make my database safe?
They block the usual form of a command, like prisma migrate reset. Claude Code’s docs say a deny rule “isn’t a security boundary around the program”, so the same command written another way can slip past. That’s why the test database and backups come first.
What is PRISMA_USER_CONSENT_FOR_DANGEROUS_AI_ACTION?
Prisma blocks dangerous commands like prisma migrate reset --force when an AI agent runs them. This variable unblocks them, and Prisma says its value must be the exact text of the user’s consent message. Type that consent yourself, after checking which database it hits, and never let the agent set it.
Does Aster check my backups or my agent’s permissions?
No. Aster reads your GitHub repository and flags leaked secrets, Supabase RLS policies, Firebase rules and vulnerable packages. It doesn’t check your backups, which database your agent uses, or your Claude Code settings.
Back up, give the agent a practice lane, raise the bumpers. The agent works on a copy; your users’ data stays out of its reach. When you want a second look at the code itself, your first repository audit is free: Aster flags leaked secrets, Supabase policies, Firebase rules and vulnerable packages in your repo.
Source notebook7 links
- GitHub anthropics/claude-code issue #33183: “Claude Code ran destructive prisma db push against production database” (March 11, 2026)
- Prisma Docs: Prisma CLI reference (migrate reset, db push, migrate deploy, AI agent guardrails)
- Claude Code Docs: Checkpointing (what /rewind restores)
- Supabase Docs: Database Backups (daily backups per plan, restore, PITR)
- Supabase CLI reference: supabase db dump (and supabase db reset)
- Supabase Docs: Backup and Restore using the CLI
- Claude Code Docs: Configure permissions (deny rules and their limits)

