Files
acmcc/supabase/migrations/20260424175636_5287209e-3dad-4b1d-b945-d2ba27f5411c.sql
T
2026-06-01 20:19:26 -04:00

10 lines
495 B
SQL

ALTER TABLE public.vendors ADD COLUMN IF NOT EXISTS association_ids uuid[] NOT NULL DEFAULT ARRAY[]::uuid[];
-- Backfill: ensure existing single association_id is included in the array
UPDATE public.vendors
SET association_ids = ARRAY[association_id]
WHERE association_id IS NOT NULL
AND (association_ids IS NULL OR NOT (association_id = ANY(association_ids)));
-- Index for fast filtering
CREATE INDEX IF NOT EXISTS idx_vendors_association_ids ON public.vendors USING GIN (association_ids);