-- Migration: 002_dedup_unique_index -- Add a UNIQUE index on (camera_id, recorded_at) to enforce hub-side -- deduplication for ESP32 offline status replay (CUB-239). -- This prevents race-condition double-inserts that a pure SELECT COUNT(*) -- check cannot guard against. CREATE UNIQUE INDEX IF NOT EXISTS idx_status_logs_unique_entry ON status_logs(camera_id, recorded_at);