[UI] Support UI partial control
[validation.git] / ui / db-scripts / akraino_blueprint_validation_db.sql
1 /*
2  * Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 SET FOREIGN_KEY_CHECKS=1;
18
19 use akraino;
20
21 DROP TABLE IF EXISTS blueprint_instance_for_validation;
22 DROP TABLE IF EXISTS blueprint;
23 DROP TABLE IF EXISTS silo;
24 DROP TABLE IF EXISTS timeslot;
25 DROP TABLE IF EXISTS lab;
26 DROP TABLE IF EXISTS w_robot_test_result;
27 DROP TABLE IF EXISTS validation_test_result;
28 DROP TABLE IF EXISTS submission;
29
30 create table lab (
31    id bigint not NULL AUTO_INCREMENT,
32    lab text not NULL unique,
33    CONSTRAINT id_pk PRIMARY KEY (id)
34 );
35
36 create table timeslot (
37    id bigint not NULL AUTO_INCREMENT,
38    start_date_time text,
39    duration text,
40    lab_id bigint not NULL,
41    CONSTRAINT id_pk PRIMARY KEY (id),
42    CONSTRAINT lab_id_fk FOREIGN KEY (lab_id)
43       REFERENCES lab (id) MATCH SIMPLE
44       ON UPDATE NO ACTION ON DELETE NO ACTION
45 );
46
47 create table silo (
48    id bigint not NULL AUTO_INCREMENT,
49    silo text not NULL,
50    lab_id bigint not NULL unique,
51    CONSTRAINT id_pk PRIMARY KEY (id),
52    CONSTRAINT lab_id_fk2 FOREIGN KEY (lab_id)
53       REFERENCES lab (id) MATCH SIMPLE
54       ON UPDATE NO ACTION ON DELETE NO ACTION
55 );
56
57 CREATE TABLE blueprint
58 (
59    id bigint not NULL AUTO_INCREMENT,
60    blueprint_name varchar(20) not NULL unique,
61    CONSTRAINT id_pk PRIMARY KEY (id)
62 );
63
64 CREATE TABLE blueprint_instance_for_validation
65 (
66    id bigint not NULL AUTO_INCREMENT,
67    blueprint_id bigint not NULL,
68    version text not NULL,
69    layer text not NULL,
70    layer_description text not NULL,
71    CONSTRAINT id_pk PRIMARY KEY (id),
72    CONSTRAINT blueprint_id_fk FOREIGN KEY (blueprint_id)
73       REFERENCES blueprint (id) MATCH SIMPLE
74       ON UPDATE NO ACTION ON DELETE NO ACTION,
75    unique (version, layer, blueprint_id)
76 );
77
78 CREATE TABLE submission
79 (
80    id bigint not NULL AUTO_INCREMENT,
81    status text not NULL,
82    timeslot_id bigint not NULL,
83    CONSTRAINT id_pk PRIMARY KEY (id),
84    CONSTRAINT timeslot_id_fk FOREIGN KEY (timeslot_id)
85       REFERENCES timeslot (id) MATCH SIMPLE
86       ON UPDATE NO ACTION ON DELETE NO ACTION
87 );
88
89 CREATE TABLE validation_test_result
90 (
91    id bigint not NULL AUTO_INCREMENT,
92    blueprint_name varchar(20) not NULL,
93    version text not NULL,
94    lab_id bigint not NULL,
95    timestamp text,
96    all_layers boolean,
97    optional boolean,
98    result boolean,
99    submission_id bigint,
100    date_of_storage text,
101    CONSTRAINT id_pk PRIMARY KEY (id),
102    CONSTRAINT lab_id_fk3 FOREIGN KEY (lab_id)
103       REFERENCES lab (id) MATCH SIMPLE
104       ON UPDATE NO ACTION ON DELETE NO ACTION,
105    CONSTRAINT submission_id_fk FOREIGN KEY (submission_id)
106       REFERENCES submission (id) MATCH SIMPLE
107       ON UPDATE NO ACTION ON DELETE NO ACTION,
108    unique (timestamp, lab_id)
109 );
110
111 CREATE TABLE w_robot_test_result
112 (
113    id bigint not NULL AUTO_INCREMENT,
114    layer text not NULL,
115    validation_test_result_id bigint not NULL,
116    robot_test_results LONGTEXT,
117    CONSTRAINT id_pk PRIMARY KEY (id),
118    CONSTRAINT validation_test_result_id_fk FOREIGN KEY (validation_test_result_id)
119       REFERENCES validation_test_result (id) MATCH SIMPLE
120       ON UPDATE NO ACTION ON DELETE NO ACTION,
121    unique (layer, validation_test_result_id)
122 );
123
124 commit;