Skip to content

Commit 257789b

Browse files
authored
chore: grant DML on public tables to API roles in test schema migration (#65)
1 parent 7b6f453 commit 257789b

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

supabase/migrations/20250224164421_init.sql

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,16 @@ SELECT status
182182
from users
183183
WHERE username = name_param;
184184
$$
185-
LANGUAGE SQL IMMUTABLE;
185+
LANGUAGE SQL IMMUTABLE;
186+
187+
-- Tables created by the `postgres` role in the `public` schema no longer inherit
188+
-- SELECT/INSERT/UPDATE/DELETE for the API roles under current Supabase CLI default privileges
189+
-- (https://supabase.com/changelog/45329-breaking-change-tables-not-exposed-to-data-and-graphql-api-automatically),
190+
-- so the privileges must be granted explicitly.
191+
grant select, insert, update, delete on all tables in schema public to anon, authenticated, service_role;
192+
grant usage, select on all sequences in schema public to anon, authenticated, service_role;
193+
grant execute on all functions in schema public to anon, authenticated, service_role;
194+
195+
alter default privileges in schema public grant select, insert, update, delete on tables to anon, authenticated, service_role;
196+
alter default privileges in schema public grant usage, select on sequences to anon, authenticated, service_role;
197+
alter default privileges in schema public grant execute on functions to anon, authenticated, service_role;

0 commit comments

Comments
 (0)