ALTER TABLE alert_occurrences DROP CONSTRAINT alert_occurrences_event_type_check; ALTER TABLE alert_occurrences ADD CONSTRAINT alert_occurrences_event_type_check CHECK (event_type IN ('evaluation', 'transition', 'acknowledge', 'unacknowledge')); CREATE INDEX alert_instances_acknowledged_idx ON alert_instances (acknowledged_at DESC, id ASC) WHERE current_state = 'acknowledged';