AI-run migration or SQL wiped the Supabase database (tables and data gone)
Symptoms
- Tables and all their rows are gone after asking the AI to 'clean up the schema' or 'reset the database', or after a migration command
- One documented case: a builder ran 'migration down --last 1' and lost the entire database
- Every query against the dropped tables now errors
- If the whole project was deleted: Supabase confirms deleted projects cannot be restored, with no known cases of support recovering one
Why it happens
AI agents translate vague requests into destructive SQL
Requests like 'clean up the schema' or 'reset the database' become DROP TABLE, TRUNCATE, or db reset commands, run without any understanding that the data is production.
Down migrations do not undo data
A down migration executes whatever drop statements correspond to the up migration. It removes structures; it does not restore rows.
No dev/prod separation by default
Lovable-style workflows have no dev and production database split out of the box, so experiments run against the only copy of the data.
Free-plan Supabase has no downloadable automated backups
When the wipe happens on a free project, there is often simply nothing to restore from.
How to fix it
- Stop all prompting right nowThe moment you notice missing data, stop asking the AI to fix anything. Further fixes can overwrite what is left or run more migrations. This step costs nothing and protects every remaining recovery option.
- Check Database > BackupsPro-plan projects have daily backups, or point-in-time recovery if enabled; restore to the moment before the wipe. Free-plan projects have no dashboard backups, so move straight to the next step.
- Hunt for any offline copyLook for a local pg_dump, CSV exports, or a second environment that still holds the data. Ask teammates; someone's laptop may hold the only surviving copy.
- Do not expect Lovable's history to helpLovable's version history restores code only. Reverting the Lovable project does not restore database rows, no matter how far back you go.
- Rebuild the schema from migration filesIf the data is unrecoverable, the migration files in supabase/migrations/ can rebuild the structure and RLS policies. Honest note: this brings back the shape of the database, not its contents.
- Set up guardrails before the next experimentKeep a separate dev Supabase project (or supabase CLI local dev) and point AI experiments there, never at production. Schedule a cron running pg_dump against the connection string, and require the AI to show any SQL containing DROP, TRUNCATE, or DELETE in Chat or Plan mode before you approve it.
How to prevent it
- Keep a separate dev Supabase project or a supabase CLI local environment for AI experiments; never point them at production
- Run your own scheduled backups; a cron running pg_dump against the connection string is enough
- Require the AI to show migrations and SQL before running anything containing DROP, TRUNCATE, or DELETE
- Move production data onto a plan with daily backups or PITR before there is data worth losing
Tools that actually fix this
Recommended because they address the failure mode above, not because of the payout. Some are affiliate links; see how we choose.
Automated, scheduled backups of your database and storage so the AI's next confident refactor is survivable. Set it once and stop trusting an agent with your only copy.
Try SimpleBackups →Backup and recovery for your Git repositories, so a force-push or an agent's cleanup does not take your history with it. Free for open-source projects.
Try GitProtect →Frequently asked questions
Can I recover a Supabase database after an AI migration wiped it?
It depends on your plan. Pro-plan Supabase projects have daily backups (or point-in-time recovery if enabled), so you can restore to the moment before the wipe from Database > Backups. Free-plan projects have no dashboard backups, so recovery depends entirely on a local pg_dump, CSV export, or a second environment that still holds the data.
Does reverting my Lovable project restore the database?
No. Lovable's version history restores code only, so reverting the Lovable project brings back your files but not your database rows. Database recovery has to come from Supabase backups or your own exports.
Can Supabase support restore a deleted project?
No. Supabase confirms that deleted projects cannot be restored, and there are no known cases of support recovering one. Treat project deletion as permanent and keep your own backups for anything you cannot afford to lose.
Does running a down migration undo the data changes?
No. A down migration executes whatever drop statements correspond to the up migration; it removes structures rather than restoring rows. In one documented case, running 'migration down --last 1' cost a builder the entire database.
Sources
- Supabase GitHub discussion #43997
- Supabase GitHub discussion #33919
- Answer Overflow thread on a wiped Supabase database
- dev.to: Setting up local Supabase when migration scripts error out
Related errors
Replit Agent deleted my database (the SaaStr incident)
The AI agent deleted my code or database and there's no backup
Supabase project paused for inactivity and your live app went dead
Cursor Agent Deleted My Files (Wiped Uncommitted Work)
Bolt.new project disappeared (or chat history gone, or rollback made it worse)
The Vibe Oops briefing
One email when something ships to production that should not have. New incidents, new error guides, no filler.