-- 005_analytics.sql -- Migration for MTTR and Noise Reduction Analytics -- Add resolved_at column for MTTR calculation (if not exists) ALTER TABLE incidents ADD COLUMN IF NOT EXISTS resolved_at TIMESTAMPTZ; -- Add pd_escalated_at column for PagerDuty auto-escalation idempotency ALTER TABLE incidents ADD COLUMN IF NOT EXISTS pd_escalated_at TIMESTAMPTZ; -- Add index on created_at for time-series queries (trends, noise stats) CREATE INDEX IF NOT EXISTS idx_incidents_created_at ON incidents(created_at); CREATE INDEX IF NOT EXISTS idx_alerts_received_at ON alerts(received_at);