From 4adb933bda2f8cb0add680e16b68df3a1e502c17 Mon Sep 17 00:00:00 2001 From: bruce Date: Fri, 10 Jan 2025 09:12:20 +0800 Subject: [PATCH] feat: Update reading table schema Using id and origin as index for TimescaleDB integration Signed-off-by: bruce --- cmd/core-data/res/db/sql/01-tables.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/core-data/res/db/sql/01-tables.sql b/cmd/core-data/res/db/sql/01-tables.sql index 4e58b038d0..47a669d652 100644 --- a/cmd/core-data/res/db/sql/01-tables.sql +++ b/cmd/core-data/res/db/sql/01-tables.sql @@ -15,7 +15,7 @@ CREATE TABLE IF NOT EXISTS core_data.event ( -- core_data.reading is used to store the reading information CREATE TABLE IF NOT EXISTS core_data.reading ( - id UUID PRIMARY KEY, + id UUID, event_id UUID, devicename TEXT, profilename TEXT, @@ -32,3 +32,6 @@ CREATE TABLE IF NOT EXISTS core_data.reading ( FOREIGN KEY(event_id) REFERENCES core_data.event(id) ); + +CREATE UNIQUE INDEX IF NOT EXISTS idx_reading_id_origin + ON core_data.reading(id, origin) -- Using id and origin as index for TimescaleDB integration