48 lines
1.1 KiB
MySQL
48 lines
1.1 KiB
MySQL
|
create table controllers
|
||
|
(
|
||
|
id INTEGER
|
||
|
PRIMARY KEY
|
||
|
AUTOINCREMENT,
|
||
|
uid BLOB
|
||
|
NOT NULL
|
||
|
UNIQUE,
|
||
|
name VARCHAR(128),
|
||
|
command_port INTEGER
|
||
|
);
|
||
|
|
||
|
create table relays
|
||
|
(
|
||
|
number INTEGER
|
||
|
PRIMARY KEY
|
||
|
NOT NULL,
|
||
|
name VARCHAR(128)
|
||
|
);
|
||
|
|
||
|
create table schedules
|
||
|
(
|
||
|
id INTEGER
|
||
|
PRIMARY KEY
|
||
|
AUTOINCREMENT,
|
||
|
uid BLOB
|
||
|
NOT NULL
|
||
|
UNIQUE,
|
||
|
name VARCHAR(128),
|
||
|
periods BLOB
|
||
|
);
|
||
|
|
||
|
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');
|