Skip to main content

Supabase rows deleted and you don't know who did it? Stop it, check the logs, restore safely

Five usual causes, the grants-and-policies fix, how long Supabase keeps logs on each plan, and why you restore to a new project instead of over the live one.

Updated 7 min readMarkdown

You open your Supabase table and rows are gone. Orders, users, posts, whatever the app stores: fewer than yesterday, or none. Nobody on your team says they ran anything.

Before you restore, you need to answer two questions in the right order: how do you stop it happening again, and how do you get the rows back safely? And somewhere in there, whether anyone actually broke in, or whether this is a mistake. Here's the sequence, with what Supabase's docs say at each step.

What usually deletes rows

There's no recycle bin for table data in Postgres: a SQL delete is final unless you have a backup. In AI-built apps, five causes explain most cases:

  1. A table with RLS off, or a delete policy that allows everyone. Anyone with your public key can delete rows through the API.
  2. A leaked service_role or secret key. It bypasses RLS, so it can delete anything.
  3. Your own code or your AI tool. A delete with no where clause, a truncate, a drop table, or a database reset run against the live project.
  4. Someone in the Dashboard. A command in the SQL editor on the wrong project.
  5. A foreign key with on delete cascade. Deleting one parent row deletes every child row.

The first two are attacks. The last three are mistakes. The first step is working out which, because the fix differs.

Step 1: Stop more deletes (before you restore anything)

Supabase's RLS guide is explicit about the underlying risk: "A table in an exposed schema without RLS is readable and writable by any role with a grant on it," and "adding policies doesn't remove" the default grants. On existing projects, a new table in public starts with every privilege, including delete and truncate, already granted to anon, authenticated and service_role.

Run these in the SQL editor, one table at a time:

alter table public.orders enable row level security;
revoke all on table public.orders from anon, authenticated;
-- then grant back only what the app needs, e.g.
grant select, insert, update on table public.orders to authenticated;

After RLS is enabled, the API returns nothing and accepts no changes until a policy allows it. Revoking the grants matters separately, because a policy can't take a grant back. Don't grant delete unless users truly need to delete that table's rows, and then only with a policy that checks ownership.

Then look for the open doors. These queries only read:

-- tables with RLS off
select schemaname, tablename from pg_tables
where schemaname = 'public' and not rowsecurity;

-- delete policies; a qual of "true" means every row
select tablename, policyname, roles, cmd, qual from pg_policies
where schemaname = 'public' and cmd in ('DELETE', 'ALL');

If qual is true and roles includes anon or public, a visitor with no account could delete those rows. Drop that policy.

Step 2: Work out whether it was an attack

Check the logs now. Supabase keeps API and database logs for a limited time that depends on your plan: 1 day on Free, 7 on Pro, 28 on Team and 90 on Enterprise. If you're on Free, evidence may already be gone, so look today.

In the Dashboard, open Logs, set the time range to cover when the rows disappeared, and filter for API requests using the DELETE method against your table, and for SQL editor or database activity. You're looking for:

  • DELETE requests from IP addresses or user agents you don't recognize
  • requests at times nobody on your team was working
  • a burst of deletes across many rows

Search your own code. Look in the repository and migration files for .delete(), delete from, truncate and drop table, and check the where clause on each. Look at what your AI tool wrote recently.

If requests came through the API with your public key, the table was open. If deletions bypassed RLS entirely, assume the service_role key leaked and rotate it. Search your live JavaScript and your GitHub repository for service_role and sb_secret_. Rotation steps: https://proofforge.live/leaked-keys/supabase-service-role and https://proofforge.live/guides/i-leaked-an-api-key-what-now

Step 3: Get the rows back safely

Supabase's backup docs say all Pro, Team and Enterprise projects are backed up daily. Pro keeps the last 7 days, Team 14, and Enterprise up to 30. Point-in-Time Recovery (PITR) is a paid add-on that lets you restore to a chosen moment, with a worst-case recovery point objective of two minutes by default. Free-plan projects have no automatic backups, and Supabase recommends exporting your own with supabase db dump. If you're on Free and nothing was exported, there may be nothing to restore from.

Supabase's guidance on recovery is the part people get wrong: restore to a new project, not over the live one. Per the docs, restoring to a new project "is the safe way to get deleted rows back." Restore from a physical backup that predates the deletion or, if the deletion was too recent, enable PITR and pick the exact time before it. Then copy only the rows you need into your live project.

Things to know before you start, from the same docs:

  • the feature is available on paid plans with physical backups enabled
  • the new project incurs additional monthly cost
  • it copies the whole database, including extensions that run jobs such as pg_cron and pg_net, and those jobs start running as soon as the restore finishes
  • settings like some configuration aren't carried over, so the new project won't behave exactly like the original until you reconfigure it
  • backups don't include files in Storage, only metadata about them

Restoring over the live project replaces everything since the restore point and takes the project offline while it runs.

Step 4: Prove the door is closed

Don't restore data into a project that's still open. After the policies are tightened and keys rotated, check from outside:

  1. Signed out, private window: request your table through the REST API using only the public key. You should get nothing, or an error.
  2. Two accounts: try to delete user A's row as user B. It should fail. This builds a script to run on your own machine: https://proofforge.live/two-account-test
  3. Run the free scan on your live URL. ProofForge's scan is read-only: it can show whether secret keys are in your JavaScript and whether an anonymous visitor can read your tables. It never writes or deletes, so it cannot tell you whether a delete would succeed. That's what the policy and grant queries above are for. Run it here: https://proofforge.live

Related checks: https://proofforge.live/fix/supabase-rls-disabled and https://proofforge.live/fix/supabase-rls-using-true. You can also test your tables by hand with https://proofforge.live/tools/supabase-rls-checker.

Why the $9 helps

After an incident, the slow part is the loop between your builder and the database: tighten, break, loosen, tighten again, each round spending credits. ProofForge's free scan shows your grade, every finding's severity and impact, and the top fix in full. $9 once unlocks every finding with exact code fixes and prompts for your builder. Fix + Guard ($29 once) rescans on every deploy for 30 days, so a later prompt can't quietly reopen what you closed. There's a 14-day refund and no subscription: https://proofforge.live/pricing

Sources, checked December 1, 2026:

  • Supabase docs, "Row Level Security" (grants and policies), supabase.com/docs/guides/database/postgres/row-level-security
  • Supabase docs, "Database Backups," supabase.com/docs/guides/platform/backups
  • Supabase docs, "Restore to a new project," supabase.com/docs/guides/platform/clone-project
  • Supabase docs, "Logs in Studio" (retention by plan), supabase.com/docs/guides/observability/logs
  • ProofForge tiers, proofforge.live/pricing.json
SSqlOtter3d ago

For the restore-to-a-new-project step, I’d load exports from the restored and current tables into a scratch database. Join by primary key and count two groups separately: rows missing from the current export, and rows whose keys still exist but whose business values differ. IS DISTINCT FROM handles NULL when comparing those values. Only the first group is a candidate for reinsertion. I work on SqlOtter, and its SQL Editor can run that comparison against the scratch database.

More from this blog