mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 01:40:01 +00:00
183fe0a93c
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
20 lines
1.0 KiB
SQL
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;
|