From d8cb3e9c51ccc05aac1f2093b04c33e064ac7530 Mon Sep 17 00:00:00 2001 From: tr00d Date: Wed, 8 Jul 2026 14:35:26 +0200 Subject: [PATCH] chore: grant DML on public tables to API roles in test schema migration Tables created by the `postgres` role in the `public` schema no longer inherit SELECT/INSERT/UPDATE/DELETE for anon/authenticated/service_role under current Supabase CLI default privileges (Supabase changelog 45329, effective 2026-05-30), so 20 of 30 tests failed with "permission denied for table todos" (42501). Grant the privileges explicitly in the migration, plus usage on sequences (identity columns) and execute on functions. Default privileges are altered too so tables added by future migrations stay covered. Same fix as supabase-community/supabase-csharp#268 and supabase-community/postgrest-csharp#121. Co-Authored-By: Claude Fable 5 --- supabase/migrations/20250224164421_init.sql | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/supabase/migrations/20250224164421_init.sql b/supabase/migrations/20250224164421_init.sql index 718e09b..ec42e4e 100644 --- a/supabase/migrations/20250224164421_init.sql +++ b/supabase/migrations/20250224164421_init.sql @@ -182,4 +182,16 @@ SELECT status from users WHERE username = name_param; $$ - LANGUAGE SQL IMMUTABLE; \ No newline at end of file + LANGUAGE SQL IMMUTABLE; + +-- Tables created by the `postgres` role in the `public` schema no longer inherit +-- SELECT/INSERT/UPDATE/DELETE for the API roles under current Supabase CLI default privileges +-- (https://supabase.com/changelog/45329-breaking-change-tables-not-exposed-to-data-and-graphql-api-automatically), +-- so the privileges must be granted explicitly. +grant select, insert, update, delete on all tables in schema public to anon, authenticated, service_role; +grant usage, select on all sequences in schema public to anon, authenticated, service_role; +grant execute on all functions in schema public to anon, authenticated, service_role; + +alter default privileges in schema public grant select, insert, update, delete on tables to anon, authenticated, service_role; +alter default privileges in schema public grant usage, select on sequences to anon, authenticated, service_role; +alter default privileges in schema public grant execute on functions to anon, authenticated, service_role; \ No newline at end of file