From 679f2780752bd4ee928a2b68013ac102d19eb4da Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 26 Jan 2026 12:10:21 +0100 Subject: [PATCH] Grant service_role full access to all public tables Added GRANT ALL for service_role on: - membership_statuses, membership_types, members tables - All tables and sequences in public schema - Default privileges for future tables Fixes 'permission denied' errors during admin setup. Co-Authored-By: Claude Opus 4.5 --- deploy/init.sql | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/deploy/init.sql b/deploy/init.sql index 4221a20..02379ee 100644 --- a/deploy/init.sql +++ b/deploy/init.sql @@ -198,6 +198,11 @@ CREATE TRIGGER members_updated_at FOR EACH ROW EXECUTE FUNCTION update_updated_at(); +-- Grant service_role full access to core tables +GRANT ALL ON public.membership_statuses TO service_role; +GRANT ALL ON public.membership_types TO service_role; +GRANT ALL ON public.members TO service_role; + -- DUES PAYMENTS CREATE TABLE public.dues_payments ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), @@ -1406,6 +1411,17 @@ ALTER TABLE public.members ADD COLUMN IF NOT EXISTS onboarding_completed_at TIME CREATE INDEX IF NOT EXISTS idx_members_payment_deadline ON public.members(payment_deadline) WHERE payment_deadline IS NOT NULL; +-- ============================================ +-- GRANT SERVICE_ROLE ACCESS TO ALL TABLES +-- ============================================ +-- Ensure service_role has full access to all public tables +GRANT ALL ON ALL TABLES IN SCHEMA public TO service_role; +GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO service_role; + +-- Set default privileges for future tables +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO service_role; +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role; + -- ============================================ -- END OF COMBINED MIGRATIONS -- ============================================