Start rust rewrite
This commit is contained in:
commit
12d57d020f
22 changed files with 2599 additions and 0 deletions
10
sql/cache.sql
Normal file
10
sql/cache.sql
Normal file
|
@ -0,0 +1,10 @@
|
|||
-- a key-value table used for the json-cache
|
||||
|
||||
CREATE TABLE cache (
|
||||
key STRING
|
||||
PRIMARY KEY,
|
||||
value TEXT
|
||||
NOT NULL,
|
||||
expiration INT
|
||||
DEFAULT 0
|
||||
);
|
83
sql/migration_0.sql
Normal file
83
sql/migration_0.sql
Normal file
|
@ -0,0 +1,83 @@
|
|||
-- base migration
|
||||
|
||||
CREATE TABLE controllers
|
||||
(
|
||||
id INTEGER
|
||||
PRIMARY KEY
|
||||
AUTOINCREMENT,
|
||||
uid BLOB
|
||||
NOT NULL
|
||||
UNIQUE,
|
||||
name VARCHAR(128),
|
||||
ip VARCHAR(16),
|
||||
port INTEGER,
|
||||
relay_count INTEGER,
|
||||
active BOOLEAN
|
||||
NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE relays
|
||||
(
|
||||
id INTEGER
|
||||
PRIMARY KEY
|
||||
AUTOINCREMENT,
|
||||
name VARCHAR(128),
|
||||
number INTEGER
|
||||
NOT NULL,
|
||||
controller_id INTEGER
|
||||
NOT NULL
|
||||
REFERENCES controllers (id)
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE schedules
|
||||
(
|
||||
id INTEGER
|
||||
PRIMARY KEY
|
||||
AUTOINCREMENT,
|
||||
uid BLOB
|
||||
NOT NULL
|
||||
UNIQUE,
|
||||
name VARCHAR(128),
|
||||
periods BLOB
|
||||
);
|
||||
|
||||
CREATE TABLE tags
|
||||
(
|
||||
id INTEGER
|
||||
PRIMARY KEY
|
||||
AUTOINCREMENT,
|
||||
tag VARCHAR(128)
|
||||
NOT NULL
|
||||
UNIQUE
|
||||
);
|
||||
|
||||
CREATE TABLE junction_tag
|
||||
(
|
||||
tag_id INTEGER
|
||||
NOT NULL
|
||||
REFERENCES tags (id)
|
||||
ON DELETE CASCADE,
|
||||
relay_id INTEGER
|
||||
REFERENCES relays (id)
|
||||
ON DELETE CASCADE,
|
||||
schedule_id INTEGER
|
||||
REFERENCES schedules (id)
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE junction_relay_schedule
|
||||
(
|
||||
weekday SMALLINT
|
||||
NOT NULL,
|
||||
relay_id INTEGER
|
||||
REFERENCES relays (id)
|
||||
ON DELETE CASCADE,
|
||||
schedule_id INTEGER
|
||||
DEFAULT 1
|
||||
REFERENCES schedules (id)
|
||||
ON DELETE SET DEFAULT
|
||||
);
|
||||
|
||||
INSERT INTO schedules (uid, name, periods) VALUES (x'6f666600000000000000000000000000', 'off', x'00');
|
||||
INSERT INTO schedules (uid, name, periods) VALUES (x'6f6e0000000000000000000000000000', 'on', x'010000009F05');
|
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 macro_actions
|
||||
(
|
||||
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