ALTER TABLE telemetry_alarms
    ADD COLUMN IF NOT EXISTS acknowledged BOOLEAN,
    ADD COLUMN IF NOT EXISTS acknowledged_at TIMESTAMPTZ,
    ADD COLUMN IF NOT EXISTS acknowledged_by UUID;

ALTER TABLE telemetry_alarms
    ALTER COLUMN acknowledged SET DEFAULT FALSE;

CREATE INDEX IF NOT EXISTS idx_telemetry_alarms_acknowledged
    ON telemetry_alarms(project_id, acknowledged, timestamp DESC);
