generated from CubeCraft-Creations/Tracehound
74c8697e57
- Add migration 002: UNIQUE index on status_logs(camera_id, recorded_at) - Upgrade migration system to version-tracked (schema_version table) - Prevents race-condition double-inserts that application-level COUNT(*) check cannot guard against - Complements existing application-level dedup from CUB-230
9 lines
381 B
SQL
9 lines
381 B
SQL
-- 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);
|