-- Add 'claiming' status to outbox CHECK constraint and add claim timeout index

ALTER TABLE cs_platform_event_outbox
DROP CONSTRAINT IF EXISTS chk_cs_platform_event_outbox_status;

ALTER TABLE cs_platform_event_outbox
ADD CONSTRAINT chk_cs_platform_event_outbox_status
CHECK (status IN ('pending','retrying','delivered','dead_letter','claiming'));

CREATE INDEX IF NOT EXISTS idx_cs_platform_event_outbox_claiming_timeout
ON cs_platform_event_outbox(status, updated_at);
