Files
acmcc/supabase/migrations/20260322062450_7acd2946-b2e5-4808-a7f8-ea3532e262b2.sql
2026-06-01 20:19:26 -04:00

20 lines
1.0 KiB
SQL

-- Make association_id nullable so company-level accounts can exist
ALTER TABLE public.stripe_account_mappings ALTER COLUMN association_id DROP NOT NULL;
-- Drop the unique constraint on association_id (it's one-to-one) so we can have nulls
ALTER TABLE public.stripe_account_mappings DROP CONSTRAINT IF EXISTS stripe_account_mappings_association_id_fkey;
ALTER TABLE public.stripe_account_mappings DROP CONSTRAINT IF EXISTS stripe_account_mappings_association_id_key;
-- Re-add FK but allow nulls
ALTER TABLE public.stripe_account_mappings
ADD CONSTRAINT stripe_account_mappings_association_id_fkey
FOREIGN KEY (association_id) REFERENCES public.associations(id) ON DELETE CASCADE;
-- Add unique constraint that allows multiple nulls
CREATE UNIQUE INDEX IF NOT EXISTS stripe_account_mappings_association_id_unique
ON public.stripe_account_mappings (association_id) WHERE association_id IS NOT NULL;
-- Add label column for company accounts
ALTER TABLE public.stripe_account_mappings ADD COLUMN IF NOT EXISTS label TEXT;