UI initial implementation.
[validation.git] / docker / postgresql / 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 drop sequence IF EXISTS akraino.seq_timeslot;
18 drop sequence IF EXISTS akraino.seq_blueprint;
19 drop sequence IF EXISTS akraino.seq_blueprint_instance;
20 drop sequence IF EXISTS akraino.seq_submission;
21
22 drop table IF EXISTS akraino.submission;
23 drop table IF EXISTS akraino.blueprint_instance;
24 drop table IF EXISTS akraino.blueprint;
25 drop table IF EXISTS akraino.timeslot;
26
27 CREATE SCHEMA IF NOT EXISTS akraino
28  AUTHORIZATION postgres;
29
30 CREATE TABLE akraino.timeslot
31 (
32    timeslot_id bigint not NULL unique,
33    start_date_time text not NULL,
34    duration int not NULL,
35    lab text not NULL
36 )
37 WITH (
38   OIDS = FALSE
39 )
40 ;
41 ALTER TABLE akraino.timeslot
42   OWNER TO postgres;
43
44 CREATE TABLE akraino.blueprint
45 (
46    blueprint_id bigint not NULL,
47    blueprint_name text not NULL unique,
48    CONSTRAINT blueprint_id_pk PRIMARY KEY (blueprint_id)
49 )
50 WITH (
51   OIDS = FALSE
52 )
53 ;
54 ALTER TABLE akraino.blueprint
55   OWNER TO postgres;
56
57 CREATE TABLE akraino.blueprint_instance
58 (
59    blueprint_instance_id bigint not NULL,
60    blueprint_id bigint not NULL,
61    version text not NULL,
62    layer text not NULL,
63    layer_description text not NULL,
64    timeslot_id bigint not NULL unique,
65    CONSTRAINT blueprint_instance_id_pk PRIMARY KEY (blueprint_instance_id),
66    CONSTRAINT blueprint_id_fk FOREIGN KEY (blueprint_id)
67       REFERENCES akraino.blueprint (blueprint_id) MATCH SIMPLE
68       ON UPDATE NO ACTION ON DELETE NO ACTION,
69    CONSTRAINT timeslot_id_fk FOREIGN KEY (timeslot_id)
70       REFERENCES akraino.timeslot (timeslot_id) MATCH SIMPLE
71       ON UPDATE NO ACTION ON DELETE NO ACTION
72 )
73 WITH (
74   OIDS = FALSE
75 )
76 ;
77 ALTER TABLE akraino.blueprint_instance
78   OWNER TO postgres;
79
80 CREATE TABLE akraino.submission
81 (
82    submission_id bigint not NULL,
83    status text not NULL,
84    jenkins_queue_job_item_url text,
85    nexus_result_url text,
86    blueprint_instance_id bigint not NULL,
87    CONSTRAINT submission_id_pk PRIMARY KEY (submission_id),
88    CONSTRAINT blueprint_instance_id_fk FOREIGN KEY (blueprint_instance_id)
89       REFERENCES akraino.blueprint_instance (blueprint_instance_id) MATCH SIMPLE
90       ON UPDATE NO ACTION ON DELETE NO ACTION
91 )
92 WITH (
93   OIDS = FALSE
94 )
95 ;
96 ALTER TABLE akraino.submission
97   OWNER TO postgres;
98
99 CREATE SEQUENCE akraino.seq_timeslot
100   START WITH 1 INCREMENT BY 1;
101
102 CREATE SEQUENCE akraino.seq_blueprint
103   START WITH 1 INCREMENT BY 1;
104
105 CREATE SEQUENCE akraino.seq_blueprint_instance
106   START WITH 1 INCREMENT BY 1;
107
108 CREATE SEQUENCE akraino.seq_submission
109   START WITH 1 INCREMENT BY 1;
110
111 insert into akraino.timeslot values(1, now(), 10, 0);  /* stands for AT&T lab */
112 insert into akraino.timeslot values(2, now(), 1000, 0); /* stands for AT&T lab */
113 insert into akraino.timeslot values(3, now(), 10000, 0); /* stands for AT&T lab */
114 insert into akraino.timeslot values(4, now(), 100000, 0); /* stands for AT&T lab */
115 insert into akraino.timeslot values(5, now(), 100000, 0); /* stands for AT&T lab */
116
117 insert into akraino.blueprint (blueprint_id, blueprint_name) values(1, 'dummy');
118 insert into akraino.blueprint (blueprint_id, blueprint_name) values(2, 'Unicycle');
119 insert into akraino.blueprint (blueprint_id, blueprint_name) values(3, 'REC');
120
121 insert into akraino.blueprint_instance (blueprint_instance_id, blueprint_id, version, layer, layer_description, timeslot_id) values(1, 1, '0.0.2-SNAPSHOT', 0, 'Dell Hardware', 1);  /* 0 Stands for hardware layer */
122 insert into akraino.blueprint_instance (blueprint_instance_id, blueprint_id, version, layer, layer_description, timeslot_id) values(2, 2, '0.0.1-SNAPSHOT', 0, 'Dell Hardware', 2); /* 0 Stands for hardware layer */
123 insert into akraino.blueprint_instance (blueprint_instance_id, blueprint_id, version, layer, layer_description, timeslot_id) values(3, 2, '0.0.7-SNAPSHOT', 1, 'CentOS Linux 7 (Core)', 3); /* 1 Stands for OS layer */
124 insert into akraino.blueprint_instance (blueprint_instance_id, blueprint_id, version, layer, layer_description, timeslot_id) values(4, 3, '0.0.4-SNAPSHOT', 2, 'K8s with High Availability Ingress controller', 4); /* 2 Stands for k8s layer */
125 insert into akraino.blueprint_instance (blueprint_instance_id, blueprint_id, version, layer, layer_description, timeslot_id) values(5, 3, '0.0.8-SNAPSHOT', 2, 'K8s with High Availability Ingress controller', 5); /* 2 Stands for k8s layer */
126
127 commit;