blob: aa3aa65e9bb94c90885fc067b14dbc7e792cb808 [file] [log] [blame]
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -07001#
ChrisC5e9feb22017-06-21 02:38:57 -07002# Create CLDS database objects (tables, etc.)
3#
4#
ChrisC5e9feb22017-06-21 02:38:57 -07005CREATE DATABASE `cldsdb4`;
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -07006USE `cldsdb4`;
7DROP USER 'clds';
8CREATE USER 'clds';
ChrisC5e9feb22017-06-21 02:38:57 -07009GRANT ALL on cldsdb4.* to 'clds' identified by 'sidnnd83K' with GRANT OPTION;
10GRANT SELECT on mysql.proc TO 'clds';
11FLUSH PRIVILEGES;
12
13
14CREATE TABLE template (
15 template_id VARCHAR(36) NOT NULL,
16 template_name VARCHAR(80) NOT NULL,
17 template_bpmn_id VARCHAR(36) NULL,
18 template_image_id VARCHAR(36) NULL,
19 template_doc_id VARCHAR(36) NULL,
20 PRIMARY KEY (template_id),
21 UNIQUE (template_name)
22) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
23
24CREATE TABLE template_bpmn (
25 template_bpmn_id VARCHAR(36) NOT NULL,
26 template_id VARCHAR(36) NOT NULL,
27 template_bpmn_text MEDIUMTEXT NOT NULL,
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -070028 user_id VARCHAR(80),
ChrisC5e9feb22017-06-21 02:38:57 -070029 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
30 PRIMARY KEY (template_bpmn_id)
31) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
32
33CREATE TABLE template_image (
34 template_image_id VARCHAR(36) NOT NULL,
35 template_id VARCHAR(36) NOT NULL,
36 template_image_text MEDIUMTEXT NULL,
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -070037 user_id VARCHAR(80),
ChrisC5e9feb22017-06-21 02:38:57 -070038 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
39 PRIMARY KEY (template_image_id)
40) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
41
42CREATE TABLE template_doc (
43 template_doc_id VARCHAR(36) NOT NULL,
44 template_id VARCHAR(36) NOT NULL,
45 template_doc_text MEDIUMTEXT NULL,
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -070046 user_id VARCHAR(80),
ChrisC5e9feb22017-06-21 02:38:57 -070047 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
48 PRIMARY KEY (template_doc_id)
49) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
50
51CREATE TABLE model (
52 model_id VARCHAR(36) NOT NULL,
53 model_name VARCHAR(80) NOT NULL,
54 template_id VARCHAR(36) NULL,
55 model_prop_id VARCHAR(36) NULL,
56 model_blueprint_id VARCHAR(36) NULL,
57 event_id VARCHAR(36) NULL,
58 control_name_prefix VARCHAR(80) NULL,
59 control_name_uuid VARCHAR(36) NOT NULL,
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -070060 service_type_id VARCHAR(80) NULL,
61 deployment_id VARCHAR(80) NULL,
sebdet25793862018-11-08 17:11:10 +010062 deployment_status_url VARCHAR(300) NULL,
ChrisC5e9feb22017-06-21 02:38:57 -070063 PRIMARY KEY (model_id),
64 UNIQUE (model_name),
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -070065 UNIQUE (control_name_uuid),
66 UNIQUE (service_type_id),
67 UNIQUE (deployment_id)
ChrisC5e9feb22017-06-21 02:38:57 -070068) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
69
70CREATE TABLE model_properties (
71 model_prop_id VARCHAR(36) NOT NULL,
72 model_id VARCHAR(36) NOT NULL,
73 model_prop_text MEDIUMTEXT NULL,
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -070074 user_id VARCHAR(80),
ChrisC5e9feb22017-06-21 02:38:57 -070075 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
76 PRIMARY KEY (model_prop_id)
77) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
78
79CREATE TABLE model_blueprint (
80 model_blueprint_id VARCHAR(36) NOT NULL,
81 model_id VARCHAR(36) NOT NULL,
82 model_blueprint_text MEDIUMTEXT NULL,
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -070083 user_id VARCHAR(80),
ChrisC5e9feb22017-06-21 02:38:57 -070084 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
85 PRIMARY KEY (model_blueprint_id)
86) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
87
88CREATE TABLE model_instance (
89 model_instance_id VARCHAR(36) NOT NULL,
90 model_id VARCHAR(36) NOT NULL,
91 vm_name VARCHAR(250) NOT NULL,
92 location VARCHAR(250) NULL,
93 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
94 PRIMARY KEY (model_instance_id),
95 UNIQUE (model_id, vm_name)
96) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
97
98CREATE TABLE event (
99 event_id VARCHAR(36) NOT NULL,
100 model_id VARCHAR(36) NULL,
101 action_cd VARCHAR(80) NOT NULL,
102 action_state_cd VARCHAR(80) NULL,
103 prev_event_id VARCHAR(36) NULL,
104 process_instance_id VARCHAR(80) NULL,
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -0700105 user_id VARCHAR(80) NULL,
ChrisC5e9feb22017-06-21 02:38:57 -0700106 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
107 PRIMARY KEY (event_id)
108) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
109
sebdet6651e172018-09-03 14:39:21 +0200110CREATE TABLE IF NOT EXISTS tosca_model (
111 tosca_model_id VARCHAR(36) NOT NULL,
112 tosca_model_name VARCHAR(80) NOT NULL,
113 policy_type VARCHAR(80) NULL,
114 user_id VARCHAR(80),
115 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
116 PRIMARY KEY (tosca_model_id)
117) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
118
119CREATE TABLE IF NOT EXISTS tosca_model_revision (
120 tosca_model_revision_id VARCHAR(36) NOT NULL,
121 tosca_model_id VARCHAR(36) NOT NULL,
122 version DOUBLE NOT NULL DEFAULT 1,
123 tosca_model_yaml MEDIUMTEXT NULL,
124 tosca_model_json MEDIUMTEXT NULL,
125 user_id VARCHAR(80),
126 createdTimestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
127 lastUpdatedTimestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
128 PRIMARY KEY (tosca_model_revision_id),
129 CONSTRAINT tosca_model_revision_ukey UNIQUE KEY (tosca_model_id, version),
130 CONSTRAINT tosca_model_revision_fkey01 FOREIGN KEY (tosca_model_id) REFERENCES tosca_model (tosca_model_id)
131) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
132
133CREATE TABLE IF NOT EXISTS dictionary (
134 dictionary_id VARCHAR(36) NOT NULL,
135 dictionary_name VARCHAR(80) NOT NULL,
136 created_by VARCHAR(80),
137 modified_by VARCHAR(80),
138 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
139 PRIMARY KEY (dictionary_id)
140) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
141
142CREATE TABLE IF NOT EXISTS dictionary_elements (
143 dict_element_id VARCHAR(36) NOT NULL,
144 dictionary_id VARCHAR(36) NOT NULL,
145 dict_element_name VARCHAR(250) NOT NULL,
146 dict_element_short_name VARCHAR(80) NOT NULL,
147 dict_element_description VARCHAR(250),
148 dict_element_type VARCHAR(80) NOT NULL,
149 created_by VARCHAR(80),
150 modified_by VARCHAR(80),
151 timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
152 PRIMARY KEY (dict_element_id),
153 CONSTRAINT dictionary_elements_ukey UNIQUE KEY (dict_element_name, dict_element_short_name),
154 CONSTRAINT dictionary_elements_ukey_fkey01 FOREIGN KEY (dictionary_id) REFERENCES dictionary (dictionary_id)
155) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
156
ChrisC5e9feb22017-06-21 02:38:57 -0700157ALTER TABLE template
158 ADD CONSTRAINT template_bpmn_id_fkey01
159 FOREIGN KEY (template_bpmn_id)
160 REFERENCES template_bpmn (template_bpmn_id);
161
162ALTER TABLE template
163 ADD CONSTRAINT template_image_id_fkey01
164 FOREIGN KEY (template_image_id)
165 REFERENCES template_image (template_image_id);
166
167ALTER TABLE template
168 ADD CONSTRAINT template_doc_id_fkey01
169 FOREIGN KEY (template_doc_id)
170 REFERENCES template_doc (template_doc_id);
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -0700171
ChrisC5e9feb22017-06-21 02:38:57 -0700172ALTER TABLE template_bpmn
173 ADD CONSTRAINT template_id_fkey02
174 FOREIGN KEY (template_id)
175 REFERENCES template (template_id);
176
177ALTER TABLE template_image
178 ADD CONSTRAINT template_id_fkey03
179 FOREIGN KEY (template_id)
180 REFERENCES template (template_id);
181
182ALTER TABLE template_doc
183 ADD CONSTRAINT template_id_fkey04
184 FOREIGN KEY (template_id)
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -0700185 REFERENCES template (template_id);
186
ChrisC5e9feb22017-06-21 02:38:57 -0700187ALTER TABLE model
188 ADD CONSTRAINT template_id_fkey01
189 FOREIGN KEY (template_id)
190 REFERENCES template (template_id);
191
192ALTER TABLE model
193 ADD CONSTRAINT model_prop_id_fkey01
194 FOREIGN KEY (model_prop_id)
195 REFERENCES model_properties (model_prop_id);
196
197ALTER TABLE model
198 ADD CONSTRAINT model_blueprint_id_fkey01
199 FOREIGN KEY (model_blueprint_id)
200 REFERENCES model_blueprint (model_blueprint_id);
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -0700201
ChrisC5e9feb22017-06-21 02:38:57 -0700202ALTER TABLE model
203 ADD CONSTRAINT event_id_fkey01
204 FOREIGN KEY (event_id)
205 REFERENCES event (event_id);
206
207ALTER TABLE model_properties
208 ADD CONSTRAINT model_id_fkey01
209 FOREIGN KEY (model_id)
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -0700210 REFERENCES model (model_id);
ChrisC5e9feb22017-06-21 02:38:57 -0700211
212ALTER TABLE model_blueprint
213 ADD CONSTRAINT model_id_fkey02
214 FOREIGN KEY (model_id)
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -0700215 REFERENCES model (model_id);
ChrisC5e9feb22017-06-21 02:38:57 -0700216
217ALTER TABLE model_instance
218 ADD CONSTRAINT model_id_fkey04
219 FOREIGN KEY (model_id)
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -0700220 REFERENCES model (model_id);
221
ChrisC5e9feb22017-06-21 02:38:57 -0700222ALTER TABLE event
223 ADD CONSTRAINT model_id_fkey03
224 FOREIGN KEY (model_id)
Determe, Sebastien (sd378r)b3a21f72017-08-08 02:58:27 -0700225 REFERENCES model (model_id);