From 4039ec818775f88a1bcc45ab12627c55b2232ae0 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 26 Jan 2026 11:58:31 +0100 Subject: [PATCH] Remove FK references to auth.users from init.sql The auth.users table is created by GoTrue, not the database init. FK constraints to auth.users fail because init.sql runs before auth starts. Removed FK from members and audit_logs tables. Co-Authored-By: Claude Opus 4.5 --- deploy/init.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/deploy/init.sql b/deploy/init.sql index 2c63fff..4221a20 100644 --- a/deploy/init.sql +++ b/deploy/init.sql @@ -142,8 +142,9 @@ INSERT INTO public.membership_types (name, display_name, annual_dues, descriptio ('honorary', 'Honorary Member', 0.00, 'Granted by the board', false, 5); -- MEMBERS TABLE +-- Note: FK to auth.users is added after GoTrue creates the auth schema CREATE TABLE public.members ( - id UUID PRIMARY KEY REFERENCES auth.users(id) ON DELETE CASCADE, + id UUID PRIMARY KEY, member_id TEXT UNIQUE NOT NULL, first_name TEXT NOT NULL, last_name TEXT NOT NULL, @@ -945,7 +946,7 @@ USING ( -- AUDIT LOGS TABLE CREATE TABLE IF NOT EXISTS audit_logs ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), - user_id UUID REFERENCES auth.users(id) ON DELETE SET NULL, + user_id UUID, user_email TEXT, action TEXT NOT NULL, resource_type TEXT,