Files
acmcc/supabase/migrations/20260331155812_abe360f7-9722-4155-bfcd-9fc58d909b2e.sql
2026-06-01 20:19:26 -04:00

14 lines
646 B
SQL

-- Drop the unique constraint on (association_id, charge_type) to allow multiple mappings per charge type
ALTER TABLE public.buildium_gl_mappings DROP CONSTRAINT IF EXISTS buildium_gl_mappings_association_id_charge_type_key;
-- Add amount threshold columns
ALTER TABLE public.buildium_gl_mappings
ADD COLUMN IF NOT EXISTS amount_min numeric DEFAULT NULL,
ADD COLUMN IF NOT EXISTS amount_max numeric DEFAULT NULL;
-- Add a unique constraint that includes amount thresholds
ALTER TABLE public.buildium_gl_mappings
ADD CONSTRAINT buildium_gl_mappings_assoc_type_amount_unique
UNIQUE (association_id, charge_type, amount_min, amount_max);