This commit is contained in:
Mateusz Gruszczyński
2026-09-01 22:20:10 +02:00
parent 1cb62c8d0b
commit 16e0d94564
47 changed files with 2565 additions and 117 deletions
+13
View File
@@ -68,3 +68,16 @@ pub const LIST_AUTOMATIONS: &str =
pub const GET_AUTOMATION: &str = "SELECT payload FROM automations WHERE id=?1";
pub const DELETE_AUTOMATION: &str = "DELETE FROM automations WHERE id=?1";
pub const UPSERT_FLOW: &str = r#"
INSERT INTO flows(id,payload,updated_at) VALUES(?1,?2,?3)
ON CONFLICT(id) DO UPDATE SET
payload=excluded.payload,
updated_at=excluded.updated_at
"#;
pub const LIST_FLOWS: &str = "SELECT payload FROM flows ORDER BY json_extract(payload, '$.name') COLLATE NOCASE";
pub const GET_FLOW: &str = "SELECT payload FROM flows WHERE id=?1";
pub const DELETE_FLOW: &str = "DELETE FROM flows WHERE id=?1";
pub const DELETE_SCHEDULES_BY_FLOW_ID: &str = "DELETE FROM schedules WHERE json_extract(payload, '$.flow_id')=?1";
pub const DELETE_AUTOMATIONS_BY_FLOW_ID: &str = "DELETE FROM automations WHERE json_extract(payload, '$.flow_id')=?1";
+1
View File
@@ -37,6 +37,7 @@ DELETE FROM ha_readings WHERE id IN (
pub const CLEAR_CONFIGURATION: &str = r#"
DELETE FROM schedules;
DELETE FROM automations;
DELETE FROM flows;
DELETE FROM climate_groups;
DELETE FROM zones;
DELETE FROM devices;
+8
View File
@@ -50,6 +50,12 @@ CREATE TABLE IF NOT EXISTS automations (
updated_at TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS flows (
id TEXT PRIMARY KEY,
payload TEXT NOT NULL,
updated_at TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS readings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
device_id TEXT NOT NULL,
@@ -127,5 +133,7 @@ INSERT OR IGNORE INTO schema_migrations(version, applied_at)
VALUES (4, strftime('%Y-%m-%dT%H:%M:%fZ','now'));
INSERT OR IGNORE INTO schema_migrations(version, applied_at)
VALUES (5, strftime('%Y-%m-%dT%H:%M:%fZ','now'));
INSERT OR IGNORE INTO schema_migrations(version, applied_at)
VALUES (6, strftime('%Y-%m-%dT%H:%M:%fZ','now'));
"#;