Waldemar
08/25/2021, 10:44 AMDROP SCHEMA public CASCADE;
CREATE SCHEMA public;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO public;
(Background: I'm coding a tool that migrates an Airtable base to Postgres / Supabase and need to "reset" the target Supabase tables frequently. So it is a dev/test project at the moment, but once I get the migration right, I want to continue to develop the live app on top of it, so I'm a bit paranoid it will mess up something in long run)soedirgo
08/25/2021, 11:08 AMpublic
, though, that's simpler: [1]
[0] https://github.com/supabase/supabase/discussions/1829
[1] https://stackoverflow.com/questions/59720477/how-to-delete-every-table-in-a-specific-schema-in-postgres?noredirect=1&lq=1Waldemar
08/25/2021, 6:31 PMpg
(via connection string postgres://postgres:blabla@db.blabla.supabase.co:5432/postgres
), so I assume yes, I need to delete all tables in public
.
So when I run this, it shouldn't mess up anything Supabase has configured when the project was created or when a table is added via GUI?
DO $$
DECLARE
row record;
BEGIN
FOR row IN SELECT * FROM pg_tables WHERE schemaname = 'public'
LOOP
EXECUTE 'DROP TABLE public.' || quote_ident(row.tablename) || ' CASCADE';
END LOOP;
END;
$$;
?soedirgo
08/26/2021, 3:13 AMpublic