-- 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;