From b13c9d23c792ec8c1764444a96986f0800d7084a Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Thu, 16 Dec 2021 09:04:08 -0800 Subject: Initial commit of the flowerpot service At this point it can store and retrieve data from the sqlite database. Everything could definitely use some cleanup and proper error handling... --- migrations/.gitkeep | 0 migrations/2021-12-15-035955_initial-schema/down.sql | 2 ++ migrations/2021-12-15-035955_initial-schema/up.sql | 12 ++++++++++++ 3 files changed, 14 insertions(+) create mode 100644 migrations/.gitkeep create mode 100644 migrations/2021-12-15-035955_initial-schema/down.sql create mode 100644 migrations/2021-12-15-035955_initial-schema/up.sql (limited to 'migrations') diff --git a/migrations/.gitkeep b/migrations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/migrations/2021-12-15-035955_initial-schema/down.sql b/migrations/2021-12-15-035955_initial-schema/down.sql new file mode 100644 index 0000000..cf9254a --- /dev/null +++ b/migrations/2021-12-15-035955_initial-schema/down.sql @@ -0,0 +1,2 @@ +DROP TABLE data; +DROP TABLE devices; diff --git a/migrations/2021-12-15-035955_initial-schema/up.sql b/migrations/2021-12-15-035955_initial-schema/up.sql new file mode 100644 index 0000000..c9a1650 --- /dev/null +++ b/migrations/2021-12-15-035955_initial-schema/up.sql @@ -0,0 +1,12 @@ +CREATE TABLE devices ( + device_id TEXT PRIMARY KEY NOT NULL, + name TEXT NOT NULL DEFAULT "My wonderful plant" +); + +CREATE TABLE data ( + device_id TEXT NOT NULL REFERENCES devices(device_id), + timestamp DATETIME NOT NULL, + value NUMERIC NOT NULL, + PRIMARY KEY (device_id, timestamp) +); + -- cgit v1.2.3