2019-08-25 23:02:49 +00:00
|
|
|
create table meta
|
|
|
|
(
|
2020-05-05 09:42:02 +00:00
|
|
|
version_num INTEGER
|
|
|
|
NOT NULL
|
2019-08-25 23:02:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
create table controllers
|
|
|
|
(
|
2020-05-05 09:42:02 +00:00
|
|
|
id INTEGER
|
|
|
|
PRIMARY KEY
|
|
|
|
AUTOINCREMENT,
|
|
|
|
uid BLOB
|
|
|
|
NOT NULL
|
|
|
|
UNIQUE,
|
2019-08-25 23:02:49 +00:00
|
|
|
name VARCHAR(128),
|
|
|
|
ip VARCHAR(16),
|
|
|
|
port INTEGER,
|
|
|
|
relay_count INTEGER,
|
2020-05-05 09:42:02 +00:00
|
|
|
active BOOLEAN
|
|
|
|
NOT NULL
|
2019-08-25 23:02:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
create table relays
|
|
|
|
(
|
2020-05-05 09:42:02 +00:00
|
|
|
id INTEGER
|
|
|
|
PRIMARY KEY
|
|
|
|
AUTOINCREMENT,
|
|
|
|
name VARCHAR(128),
|
|
|
|
number INTEGER
|
|
|
|
NOT NULL,
|
|
|
|
controller_id INTEGER
|
|
|
|
NOT NULL
|
|
|
|
REFERENCES controllers (id)
|
2019-08-25 23:02:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
create table schedules
|
|
|
|
(
|
2020-05-05 09:42:02 +00:00
|
|
|
id INTEGER
|
|
|
|
PRIMARY KEY
|
|
|
|
AUTOINCREMENT,
|
|
|
|
uid BLOB
|
|
|
|
NOT NULL
|
|
|
|
UNIQUE,
|
2019-08-25 23:02:49 +00:00
|
|
|
name VARCHAR(128),
|
|
|
|
periods BLOB
|
|
|
|
);
|
2019-09-08 21:24:31 +00:00
|
|
|
|
2020-05-05 09:42:02 +00:00
|
|
|
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),
|
|
|
|
relay_id INTEGER
|
|
|
|
REFERENCES relays (id),
|
|
|
|
schedule_id INTEGER
|
|
|
|
REFERENCES schedules (id)
|
|
|
|
);
|
|
|
|
|
|
|
|
create table junction_relay_schedule
|
|
|
|
(
|
|
|
|
weekday SMALLINT
|
|
|
|
NOT NULL,
|
|
|
|
relay_id INTEGER
|
|
|
|
NOT NULL
|
|
|
|
REFERENCES relays (id),
|
|
|
|
schedule_id INTEGER
|
|
|
|
NOT NULL
|
|
|
|
REFERENCES schedules (id)
|
|
|
|
);
|
|
|
|
|
|
|
|
INSERT INTO schedules (uid, name, periods) VALUES (x'6f666600000000000000000000000000', 'off', x'00');
|
|
|
|
INSERT INTO schedules (uid, name, periods) VALUES (x'6f6e0000000000000000000000000000', 'on', x'010000009F05');
|
|
|
|
|