diff options
Diffstat (limited to 'migrations')
| -rw-r--r-- | migrations/.gitkeep | 0 | ||||
| -rw-r--r-- | migrations/2021-12-15-035955_initial-schema/down.sql | 2 | ||||
| -rw-r--r-- | migrations/2021-12-15-035955_initial-schema/up.sql | 12 | 
3 files changed, 14 insertions, 0 deletions
diff --git a/migrations/.gitkeep b/migrations/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/migrations/.gitkeep 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) +); +  | 
