-- AUDIT-3 (2026-05-28): add composite index (monitorId, status) on
-- Heartbeat.
--
-- The monitor-engine counts recent downs per check via:
--   prisma.heartbeat.count({ where: { monitorId, status: 'down' }, take: retries+1 })
-- Without this index MySQL has to range-scan the existing
-- (monitorId, createdAt) index and filter status server-side; with it
-- the count is served from the index alone (covering scan).
--
-- Originally bundled with a drop of dnsTimeMs / connectTimeMs / tlsTimeMs
-- columns, but those ARE populated by http.strategy + tcp.strategy
-- and consumed by analytics + reports + the NOC page — keep them.

ALTER TABLE `Heartbeat`
    ADD INDEX `Heartbeat_monitorId_status_idx` (`monitorId`, `status`);
