add: basic macro functions
add: better migration handling (transactions)
This commit is contained in:
parent
7275d66c86
commit
f67b7e9e0f
7 changed files with 122 additions and 36 deletions
|
@ -1,3 +1,5 @@
|
|||
-- a key-value table used for the json-cache
|
||||
|
||||
CREATE TABLE cache (
|
||||
key STRING
|
||||
PRIMARY KEY,
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
create table controllers
|
||||
-- base migration
|
||||
|
||||
CREATE TABLE controllers
|
||||
(
|
||||
id INTEGER
|
||||
PRIMARY KEY
|
||||
|
@ -14,7 +16,7 @@ create table controllers
|
|||
NOT NULL
|
||||
);
|
||||
|
||||
create table relays
|
||||
CREATE TABLE relays
|
||||
(
|
||||
id INTEGER
|
||||
PRIMARY KEY
|
||||
|
@ -28,7 +30,7 @@ create table relays
|
|||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
create table schedules
|
||||
CREATE TABLE schedules
|
||||
(
|
||||
id INTEGER
|
||||
PRIMARY KEY
|
||||
|
@ -40,7 +42,7 @@ create table schedules
|
|||
periods BLOB
|
||||
);
|
||||
|
||||
create table tags
|
||||
CREATE TABLE tags
|
||||
(
|
||||
id INTEGER
|
||||
PRIMARY KEY
|
||||
|
@ -50,7 +52,7 @@ create table tags
|
|||
UNIQUE
|
||||
);
|
||||
|
||||
create table junction_tag
|
||||
CREATE TABLE junction_tag
|
||||
(
|
||||
tag_id INTEGER
|
||||
NOT NULL
|
||||
|
@ -64,7 +66,7 @@ create table junction_tag
|
|||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
create table junction_relay_schedule
|
||||
CREATE TABLE junction_relay_schedule
|
||||
(
|
||||
weekday SMALLINT
|
||||
NOT NULL,
|
||||
|
|
28
sql/migration_1.sql
Normal file
28
sql/migration_1.sql
Normal file
|
@ -0,0 +1,28 @@
|
|||
-- migration to add macros
|
||||
|
||||
CREATE TABLE macros
|
||||
(
|
||||
id INTEGER
|
||||
PRIMARY KEY
|
||||
AUTOINCREMENT,
|
||||
uid BLOB
|
||||
NOT NULL
|
||||
UNIQUE,
|
||||
name VARCHAR(128)
|
||||
);
|
||||
|
||||
CREATE TABLE junction_macro
|
||||
(
|
||||
macro_id INTEGER
|
||||
NOT NULL
|
||||
REFERENCES macros (id)
|
||||
ON DELETE CASCADE,
|
||||
relay_id INTEGER
|
||||
REFERENCES relays (id)
|
||||
ON DELETE CASCADE,
|
||||
schedule_id INTEGER
|
||||
REFERENCES schedules (id)
|
||||
ON DELETE CASCADE,
|
||||
weekday SMALLINT
|
||||
NOT NULL
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue