-- Migration 091: Sag contacts primary flag DO $$ BEGIN IF NOT EXISTS ( SELECT 1 FROM information_schema.columns WHERE table_name = 'sag_kontakter' AND column_name = 'is_primary' ) THEN ALTER TABLE sag_kontakter ADD COLUMN is_primary BOOLEAN DEFAULT FALSE; END IF; END $$; -- Ensure only one primary contact per case CREATE UNIQUE INDEX IF NOT EXISTS idx_sag_kontakter_primary ON sag_kontakter (sag_id) WHERE is_primary = TRUE;