From 258bd62a7f9ac45f63f4fac71b6f17d052470f0a Mon Sep 17 00:00:00 2001 From: Danel Kungla Date: Tue, 7 Oct 2025 16:28:35 +0300 Subject: [PATCH] MED-155: add RLS to public schema --- .../20251007161700_enable_public_schema_rls.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 supabase/migrations/20251007161700_enable_public_schema_rls.sql diff --git a/supabase/migrations/20251007161700_enable_public_schema_rls.sql b/supabase/migrations/20251007161700_enable_public_schema_rls.sql new file mode 100644 index 0000000..a50f013 --- /dev/null +++ b/supabase/migrations/20251007161700_enable_public_schema_rls.sql @@ -0,0 +1,17 @@ +DO $$ +DECLARE + target_schema text := 'public'; + table_name text; +BEGIN + FOR table_name IN + SELECT c.relname + FROM pg_class c + JOIN pg_namespace n ON n.oid = c.relnamespace + WHERE n.nspname = target_schema + AND c.relkind = 'r' + LOOP + EXECUTE format('ALTER TABLE %I.%I ENABLE ROW LEVEL SECURITY;', target_schema, table_name); + END LOOP; +END $$; + +REVOKE USAGE ON SCHEMA public FROM anon, authenticated; \ No newline at end of file