Drop all tables in a Postgres schema
A guide from Supabase
Apps on Plentiful run on Supabase's open-source database, sign-in, file storage and live updates, so most of this guide applies. The differences: your app reaches its database through its own server — not Supabase's data API (supabase.from(…)) — there are no Edge Functions (your app's server does that work), and scheduled work uses Jobs. Where it says "Supabase dashboard", use your app's Dashboard. Ask the builder when in doubt.
Execute the following query to drop all tables in a given schema.
Replace my-schema-name with the name of your schema. In Supabase, the default schema is public.
This deletes all tables and their associated data. Ensure you have a recent backup before proceeding.
1do $$ declare2 r record;3begin4 for r in (select tablename from pg_tables where schemaname = 'my-schema-name') loop5 execute 'drop table if exists ' || quote_ident(r.tablename) || ' cascade';6 end loop;7end $$;This query works by listing out all the tables in the given schema and then executing a drop table for each (hence the for... loop).
You can run this query using the SQL Editor in the Supabase Dashboard, or via psql if you're connecting directly to the database.