-- Explicit schema/table/sequence/routine grants for anon/authenticated/ -- service_role. -- -- Every table in this schema relies on RLS policies to restrict access, but -- RLS only ever *narrows* what an already-GRANTed role may do — Postgres -- still checks ordinary object privileges first, independent of a role's -- BYPASSRLS flag. Some hosting platforms apply these grants automatically -- during provisioning; a *fresh* Postgres (a new local dev instance, a -- disaster-recovery restore, or CI) does not, and the migrations would fail -- there with "permission denied for table X" even for the service role. -- Making the grants explicit here makes the schema fully self-contained and -- reprovisionable from scratch. grant usage on schema public to anon, authenticated, service_role; grant all on all tables in schema public to anon, authenticated, service_role; grant all on all sequences in schema public to anon, authenticated, service_role; grant all on all routines in schema public to anon, authenticated, service_role; alter default privileges in schema public grant all on tables to anon, authenticated, service_role; alter default privileges in schema public grant all on sequences to anon, authenticated, service_role; alter default privileges in schema public grant all on routines to anon, authenticated, service_role;