From a4328134448406c596739e5eb3b5268dc8546d56 Mon Sep 17 00:00:00 2001 From: Peter Woolery Date: Tue, 14 Apr 2026 06:59:52 -0700 Subject: [PATCH] feat: camera_records table migration Co-Authored-By: Claude Sonnet 4.6 --- server/migrations/004_camera_records.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 server/migrations/004_camera_records.sql 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);