init rewrite
This commit is contained in:
parent
9a44bc494e
commit
6d828fcffc
100 changed files with 50541 additions and 2707 deletions
|
@ -1,40 +1,83 @@
|
|||
create table meta
|
||||
(
|
||||
version_num int not null
|
||||
version_num INTEGER
|
||||
NOT NULL
|
||||
);
|
||||
|
||||
create table controllers
|
||||
(
|
||||
id VARCHAR(33) not null
|
||||
primary key
|
||||
unique,
|
||||
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
|
||||
active BOOLEAN
|
||||
NOT NULL
|
||||
);
|
||||
|
||||
create table relays
|
||||
(
|
||||
id INTEGER not null
|
||||
primary key
|
||||
unique,
|
||||
name VARCHAR(128),
|
||||
number INTEGER not null,
|
||||
controller_id VARCHAR(33) not null
|
||||
references controllers (id),
|
||||
active_schedule_id VARCHAR(33)
|
||||
references schedules
|
||||
id INTEGER
|
||||
PRIMARY KEY
|
||||
AUTOINCREMENT,
|
||||
name VARCHAR(128),
|
||||
number INTEGER
|
||||
NOT NULL,
|
||||
controller_id INTEGER
|
||||
NOT NULL
|
||||
REFERENCES controllers (id)
|
||||
);
|
||||
|
||||
create table schedules
|
||||
(
|
||||
id VARCHAR(33) not null
|
||||
primary key
|
||||
unique,
|
||||
id INTEGER
|
||||
PRIMARY KEY
|
||||
AUTOINCREMENT,
|
||||
uid BLOB
|
||||
NOT NULL
|
||||
UNIQUE,
|
||||
name VARCHAR(128),
|
||||
periods BLOB
|
||||
);
|
||||
|
||||
INSERT INTO schedules (id, name, periods) VALUES ('off', 'off', x'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');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue