Files
acmcc/supabase/migrations/20260403001523_0177086a-cad3-402d-a742-4300b52112f6.sql
2026-06-01 20:19:26 -04:00

21 lines
919 B
SQL

CREATE TABLE public.vendor_coa_mappings (
id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,
association_id UUID NOT NULL REFERENCES public.associations(id) ON DELETE CASCADE,
vendor_id UUID NOT NULL REFERENCES public.vendors(id) ON DELETE CASCADE,
chart_of_accounts_id UUID NOT NULL REFERENCES public.chart_of_accounts(id) ON DELETE CASCADE,
notes TEXT,
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
UNIQUE(association_id, vendor_id)
);
ALTER TABLE public.vendor_coa_mappings ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Authenticated users can manage vendor COA mappings"
ON public.vendor_coa_mappings FOR ALL TO authenticated USING (true) WITH CHECK (true);
CREATE TRIGGER update_vendor_coa_mappings_updated_at
BEFORE UPDATE ON public.vendor_coa_mappings
FOR EACH ROW EXECUTE FUNCTION public.update_updated_at_column();