diff --git a/server/migrations/004_camera_records.sql b/server/migrations/004_camera_records.sql new file mode 100644 index 0000000..6f3fe16 --- /dev/null +++ b/server/migrations/004_camera_records.sql @@ -0,0 +1,18 @@ +-- migrations/004_camera_records.sql +-- Add camera_records table for TimerCamera-F door counter events +-- Apply: sqlite3 < migrations/004_camera_records.sql + +CREATE TABLE IF NOT EXISTS camera_records ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + device_id TEXT NOT NULL, + location_id TEXT NOT NULL, + period_start INTEGER NOT NULL, + period_end INTEGER NOT NULL, + entries INTEGER NOT NULL, + exits INTEGER NOT NULL, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + UNIQUE(device_id, period_start) +); + +CREATE INDEX IF NOT EXISTS idx_camera_location_time + ON camera_records(location_id, period_start);