-- Migration 154: add the mitigation UNIQUE/CHECK that the current code relies on. -- The reconciled (consolidated) iace_mitigations lacked the constraints from -- migrations 029/030, so CreateMitigation's `ON CONFLICT (hazard_id, name)` -- failed (SQLSTATE 42P10) and no mitigations were created. Idempotent. ALTER TABLE iace_mitigations DROP CONSTRAINT IF EXISTS iace_mitigations_hazard_name_uniq; ALTER TABLE iace_mitigations ADD CONSTRAINT iace_mitigations_hazard_name_uniq UNIQUE (hazard_id, name); CREATE INDEX IF NOT EXISTS idx_iace_mitigations_relevant ON iace_mitigations(hazard_id) WHERE is_relevant = TRUE;