-
Notifications
You must be signed in to change notification settings - Fork 3
/
schema_log.sql
38 lines (38 loc) · 1.52 KB
/
schema_log.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
CREATE TABLE log (
id INTEGER NOT NULL,
member_id INTEGER,
node_id INTEGER,
tool_id INTEGER,
resource_id INTEGER,
message VARCHAR(100),
doneby INTEGER,
time_logged DATETIME DEFAULT CURRENT_TIMESTAMP,
time_reported DATETIME DEFAULT CURRENT_TIMESTAMP,
event_type INTEGER,
event_subtype INTEGER,
PRIMARY KEY (id),
FOREIGN KEY(member_id) REFERENCES members (id) ON DELETE CASCADE,
FOREIGN KEY(node_id) REFERENCES nodes (id) ON DELETE CASCADE,
FOREIGN KEY(tool_id) REFERENCES tools (id) ON DELETE CASCADE,
FOREIGN KEY(resource_id) REFERENCES resources (id) ON DELETE CASCADE,
FOREIGN KEY(doneby) REFERENCES members (id) ON DELETE CASCADE
);
CREATE INDEX ix_log_time_logged ON log (time_logged);
CREATE INDEX ix_log_event_subtype ON log (event_subtype);
CREATE INDEX ix_log_time_reported ON log (time_reported);
CREATE INDEX ix_log_event_type ON log (event_type);
CREATE TABLE usagelog (
id INTEGER NOT NULL,
member_id INTEGER,
tool_id INTEGER,
resource_id INTEGER,
time_logged DATETIME DEFAULT CURRENT_TIMESTAMP,
time_reported DATETIME,
"idleSecs" INTEGER,
"activeSecs" INTEGER,
"enabledSecs" INTEGER,
PRIMARY KEY (id),
FOREIGN KEY(member_id) REFERENCES members (id) ON DELETE CASCADE,
FOREIGN KEY(tool_id) REFERENCES tools (id) ON DELETE CASCADE,
FOREIGN KEY(resource_id) REFERENCES resources (id) ON DELETE CASCADE
);