Home / Errors / Supabase / migration-wiped-database

AI-run migration or SQL wiped the Supabase database (tables and data gone)

Supabase Involved 30-60 minutes with backups; without them, data may be unrecoverable data risk Last verified Jul 17, 2026
The fix  Stop prompting immediately: more AI fixes can overwrite what is left or run further migrations. On a Pro plan, restore from Database > Backups (daily backups, or PITR if enabled) to the moment before the wipe. Free-plan projects have no dashboard backups; recovery depends on a local pg_dump, CSV export, or second environment. Lovable's version history restores code, never database rows.

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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.

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

Related errors

The Vibe Oops briefing

One email when something ships to production that should not have. New incidents, new error guides, no filler.