-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.sql
72 lines (66 loc) · 2.35 KB
/
db.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
DROP TABLE IF EXISTS sites;
CREATE TABLE sites
(site_id INTEGER PRIMARY KEY AUTO_INCREMENT,
site_name varchar(50) NOT NULL,
normalized_name varchar(50) NOT NULL,
num_nodes int NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
DROP TABLE IF EXISTS run;
CREATE TABLE run
(run_id int PRIMARY KEY AUTO_INCREMENT,
started_at TIMESTAMP NULL DEFAULT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
state ENUM ('STARTED','COMPLETED','TIMED_OUT','ABORTED')
);
DROP TABLE IF EXISTS processing_state;
CREATE TABLE processing_state
(site_id int NOT NULL,
run_id int NOT NULL,
started_at TIMESTAMP NULL DEFAULT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
state ENUM ('WAITING','COMPLETED','STALLED','ABORTED') NOT NULL,
running_job_count int,
completed_job_count int,
killed_job_count int,
PRIMARY KEY(site_id,run_id),
FOREIGN KEY (site_id) references sites(site_id),
FOREIGN KEY (run_id) references run(run_id));
DROP TABLE IF EXISTS jobs;
CREATE TABLE jobs
(job_id int NOT NULL PRIMARY KEY,
run_id int NOT NULL,
site_id int NOT NULL,
started_at TIMESTAMP NULL DEFAULT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
job_state ENUM ('STARTED','COMPLETED','KILLED') NOT NULL,
FOREIGN KEY (site_id) references sites(site_id),
FOREIGN KEY (run_id) references run(run_id));
DROP TABLE IF EXISTS nodes;
CREATE TABLE nodes
(node_id INTEGER PRIMARY KEY AUTO_INCREMENT,
run_id int NOT NULL,
site_id int NOT NULL,
job_id int NOT NULL,
node_name varchar(250) NOT NULL,
FOREIGN KEY (site_id) references sites(site_id),
FOREIGN KEY (run_id) references run(run_id),
FOREIGN KEY (job_id) references jobs(job_id));
DROP TABLE IF EXISTS parameters;
CREATE TABLE parameters
(job_id int NOT NULL,
run_id int NOT NULL,
site_id int NOT NULL,
node_id int NOT NULL,
paramName varchar(500) NOT NULL,
paramValue TEXT NOT NULL,
last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (job_id,paramName),
FOREIGN KEY (site_id) references sites(site_id),
FOREIGN KEY (run_id) references run(run_id),
FOREIGN KEY (job_id) references jobs(job_id));
DROP TABLE IF EXISTS job_keys;
CREATE TABLE job_keys
(run_id int NOT NULL PRIMARY KEY,
key_list TEXT NOT NULL,
FOREIGN KEY (run_id) references run(run_id)
);