-- Fix index
DROP INDEX eye.eye_primary_detection_relation_detection_id_index;
CREATE UNIQUE INDEX eye_unique_object_detection_index ON eye.primary_detection_relation USING btree(detection_id) WHERE NOT deleted;

-- Add pair constraint
CREATE UNIQUE INDEX eye_primary_detection_relation_index ON eye.primary_detection_relation USING btree(detection_id, primary_detection_id);