saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 1 | /* |
| 2 | * ============LICENSE_START======================================================= |
| 3 | * Copyright (C) 2021 Nordix Foundation |
| 4 | * ================================================================================ |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 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 | * SPDX-License-Identifier: Apache-2.0 |
| 17 | * ============LICENSE_END========================================================= |
| 18 | */ |
sebdet | 9a4661e | 2019-10-11 18:23:57 +0200 | [diff] [blame] | 19 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 20 | create table if not exists dictionary ( |
| 21 | name varchar(255) not null, |
| 22 | created_by varchar(255), |
| 23 | created_timestamp datetime(6) not null, |
| 24 | updated_by varchar(255), |
| 25 | updated_timestamp datetime(6) not null, |
| 26 | dictionary_second_level integer, |
| 27 | dictionary_type varchar(255), |
| 28 | primary key (name) |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 29 | ) engine=InnoDB; |
| 30 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 31 | create table if not exists dictionary_elements ( |
| 32 | short_name varchar(255) not null, |
| 33 | created_by varchar(255), |
| 34 | created_timestamp datetime(6) not null, |
| 35 | updated_by varchar(255), |
| 36 | updated_timestamp datetime(6) not null, |
| 37 | description varchar(255) not null, |
| 38 | name varchar(255) not null, |
| 39 | subdictionary_name varchar(255), |
| 40 | type varchar(255) not null, |
| 41 | primary key (short_name) |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 42 | ) engine=InnoDB; |
| 43 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 44 | create table if not exists dictionary_to_dictionaryelements ( |
| 45 | dictionary_name varchar(255) not null, |
| 46 | dictionary_element_short_name varchar(255) not null, |
| 47 | primary key (dictionary_name, dictionary_element_short_name) |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 48 | ) engine=InnoDB; |
| 49 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 50 | create table if not exists hibernate_sequence ( |
| 51 | next_val bigint |
| 52 | ) engine=InnoDB; |
| 53 | |
| 54 | insert into hibernate_sequence values ( 1 ); |
| 55 | |
| 56 | create table if not exists loop_element_models ( |
| 57 | name varchar(255) not null, |
| 58 | created_by varchar(255), |
| 59 | created_timestamp datetime(6) not null, |
| 60 | updated_by varchar(255), |
| 61 | updated_timestamp datetime(6) not null, |
| 62 | blueprint_yaml MEDIUMTEXT, |
| 63 | dcae_blueprint_id varchar(255), |
| 64 | loop_element_type varchar(255) not null, |
| 65 | short_name varchar(255), |
| 66 | primary key (name) |
ChrisC | 0d2232e | 2019-04-15 13:28:48 +0200 | [diff] [blame] | 67 | ) engine=InnoDB; |
| 68 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 69 | create table if not exists loop_logs ( |
| 70 | id bigint not null, |
| 71 | log_component varchar(255) not null, |
| 72 | log_instant datetime(6) not null, |
| 73 | log_type varchar(255) not null, |
| 74 | message MEDIUMTEXT not null, |
| 75 | loop_id varchar(255) not null, |
| 76 | primary key (id) |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 77 | ) engine=InnoDB; |
| 78 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 79 | create table if not exists loop_templates ( |
| 80 | name varchar(255) not null, |
| 81 | created_by varchar(255), |
| 82 | created_timestamp datetime(6) not null, |
| 83 | updated_by varchar(255), |
| 84 | updated_timestamp datetime(6) not null, |
| 85 | allowed_loop_type varchar(255), |
| 86 | blueprint_yaml MEDIUMTEXT, |
| 87 | dcae_blueprint_id varchar(255), |
| 88 | maximum_instances_allowed integer, |
| 89 | svg_representation MEDIUMTEXT, |
| 90 | unique_blueprint boolean default false, |
| 91 | service_uuid varchar(255), |
| 92 | primary key (name) |
ChrisC | 0d2232e | 2019-04-15 13:28:48 +0200 | [diff] [blame] | 93 | ) engine=InnoDB; |
| 94 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 95 | create table if not exists loopelementmodels_to_policymodels ( |
| 96 | loop_element_name varchar(255) not null, |
| 97 | policy_model_type varchar(255) not null, |
| 98 | policy_model_version varchar(255) not null, |
| 99 | primary key (loop_element_name, policy_model_type, policy_model_version) |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 100 | ) engine=InnoDB; |
| 101 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 102 | create table if not exists loops ( |
| 103 | name varchar(255) not null, |
| 104 | created_by varchar(255), |
| 105 | created_timestamp datetime(6) not null, |
| 106 | updated_by varchar(255), |
| 107 | updated_timestamp datetime(6) not null, |
| 108 | dcae_deployment_id varchar(255), |
| 109 | dcae_deployment_status_url varchar(255), |
| 110 | global_properties_json json, |
| 111 | last_computed_state varchar(255) not null, |
| 112 | svg_representation MEDIUMTEXT, |
| 113 | loop_template_name varchar(255) not null, |
| 114 | service_uuid varchar(255), |
| 115 | primary key (name) |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 116 | ) engine=InnoDB; |
| 117 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 118 | create table if not exists loops_to_microservicepolicies ( |
| 119 | loop_name varchar(255) not null, |
| 120 | microservicepolicy_name varchar(255) not null, |
| 121 | primary key (loop_name, microservicepolicy_name) |
ChrisC | 0d2232e | 2019-04-15 13:28:48 +0200 | [diff] [blame] | 122 | ) engine=InnoDB; |
| 123 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 124 | create table if not exists looptemplates_to_loopelementmodels ( |
| 125 | loop_element_model_name varchar(255) not null, |
| 126 | loop_template_name varchar(255) not null, |
| 127 | flow_order integer not null, |
| 128 | primary key (loop_element_model_name, loop_template_name) |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 129 | ) engine=InnoDB; |
| 130 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 131 | create table if not exists micro_service_policies ( |
| 132 | name varchar(255) not null, |
| 133 | created_by varchar(255), |
| 134 | created_timestamp datetime(6) not null, |
| 135 | updated_by varchar(255), |
| 136 | updated_timestamp datetime(6) not null, |
| 137 | configurations_json json, |
| 138 | json_representation json not null, |
| 139 | pdp_group varchar(255), |
| 140 | pdp_sub_group varchar(255), |
| 141 | context varchar(255), |
| 142 | dcae_blueprint_id varchar(255), |
| 143 | dcae_deployment_id varchar(255), |
| 144 | dcae_deployment_status_url varchar(255), |
| 145 | device_type_scope varchar(255), |
| 146 | shared bit not null, |
| 147 | loop_element_model_id varchar(255), |
| 148 | policy_model_type varchar(255), |
| 149 | policy_model_version varchar(255), |
| 150 | primary key (name) |
ChrisC | 0d2232e | 2019-04-15 13:28:48 +0200 | [diff] [blame] | 151 | ) engine=InnoDB; |
| 152 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 153 | create table if not exists operational_policies ( |
| 154 | name varchar(255) not null, |
| 155 | created_by varchar(255), |
| 156 | created_timestamp datetime(6) not null, |
| 157 | updated_by varchar(255), |
| 158 | updated_timestamp datetime(6) not null, |
| 159 | configurations_json json, |
| 160 | json_representation json not null, |
| 161 | pdp_group varchar(255), |
| 162 | pdp_sub_group varchar(255), |
| 163 | loop_element_model_id varchar(255), |
| 164 | policy_model_type varchar(255), |
| 165 | policy_model_version varchar(255), |
| 166 | loop_id varchar(255) not null, |
| 167 | primary key (name) |
ChrisC | 0d2232e | 2019-04-15 13:28:48 +0200 | [diff] [blame] | 168 | ) engine=InnoDB; |
| 169 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 170 | create table if not exists policy_models ( |
| 171 | policy_model_type varchar(255) not null, |
| 172 | version varchar(255) not null, |
| 173 | created_by varchar(255), |
| 174 | created_timestamp datetime(6) not null, |
| 175 | updated_by varchar(255), |
| 176 | updated_timestamp datetime(6) not null, |
| 177 | policy_acronym varchar(255), |
| 178 | policy_tosca MEDIUMTEXT, |
| 179 | policy_pdp_group json, |
| 180 | primary key (policy_model_type, version) |
ChrisC | 0d2232e | 2019-04-15 13:28:48 +0200 | [diff] [blame] | 181 | ) engine=InnoDB; |
| 182 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 183 | create table if not exists services ( |
| 184 | service_uuid varchar(255) not null, |
| 185 | name varchar(255) not null, |
| 186 | resource_details json, |
| 187 | service_details json, |
| 188 | version varchar(255), |
| 189 | primary key (service_uuid) |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 190 | ) engine=InnoDB; |
| 191 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 192 | alter table dictionary_to_dictionaryelements |
| 193 | add constraint FK68hjjinnm8nte2owstd0xwp23 |
| 194 | foreign key (dictionary_element_short_name) |
| 195 | references dictionary_elements (short_name); |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 196 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 197 | alter table dictionary_to_dictionaryelements |
| 198 | add constraint FKtqfxg46gsxwlm2gkl6ne3cxfe |
| 199 | foreign key (dictionary_name) |
| 200 | references dictionary (name); |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 201 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 202 | alter table loop_logs |
| 203 | add constraint FK1j0cda46aickcaoxqoo34khg2 |
| 204 | foreign key (loop_id) |
| 205 | references loops (name); |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 206 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 207 | alter table loop_templates |
| 208 | add constraint FKn692dk6281wvp1o95074uacn6 |
| 209 | foreign key (service_uuid) |
| 210 | references services (service_uuid); |
ChrisC | 0d2232e | 2019-04-15 13:28:48 +0200 | [diff] [blame] | 211 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 212 | alter table loopelementmodels_to_policymodels |
| 213 | add constraint FK23j2q74v6kaexefy0tdabsnda |
| 214 | foreign key (policy_model_type, policy_model_version) |
| 215 | references policy_models (policy_model_type, version); |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 216 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 217 | alter table loopelementmodels_to_policymodels |
| 218 | add constraint FKjag1iu0olojfwryfkvb5o0rk5 |
| 219 | foreign key (loop_element_name) |
| 220 | references loop_element_models (name); |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 221 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 222 | alter table loops |
| 223 | add constraint FK844uwy82wt0l66jljkjqembpj |
| 224 | foreign key (loop_template_name) |
| 225 | references loop_templates (name); |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 226 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 227 | alter table loops |
| 228 | add constraint FK4b9wnqopxogwek014i1shqw7w |
| 229 | foreign key (service_uuid) |
| 230 | references services (service_uuid); |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 231 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 232 | alter table loops_to_microservicepolicies |
| 233 | add constraint FKle255jmi7b065fwbvmwbiehtb |
| 234 | foreign key (microservicepolicy_name) |
| 235 | references micro_service_policies (name); |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 236 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 237 | alter table loops_to_microservicepolicies |
| 238 | add constraint FK8avfqaf7xl71l7sn7a5eri68d |
| 239 | foreign key (loop_name) |
| 240 | references loops (name); |
ChrisC | 0d2232e | 2019-04-15 13:28:48 +0200 | [diff] [blame] | 241 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 242 | alter table looptemplates_to_loopelementmodels |
| 243 | add constraint FK1k7nbrbugvqa0xfxkq3cj1yn9 |
| 244 | foreign key (loop_element_model_name) |
| 245 | references loop_element_models (name); |
ChrisC | 0d2232e | 2019-04-15 13:28:48 +0200 | [diff] [blame] | 246 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 247 | alter table looptemplates_to_loopelementmodels |
| 248 | add constraint FKj29yxyw0x7ue6mwgi6d3qg748 |
| 249 | foreign key (loop_template_name) |
| 250 | references loop_templates (name); |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 251 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 252 | alter table micro_service_policies |
| 253 | add constraint FKqvvdypacbww07fuv8xvlvdjgl |
| 254 | foreign key (loop_element_model_id) |
| 255 | references loop_element_models (name); |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 256 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 257 | alter table micro_service_policies |
| 258 | add constraint FKn17j9ufmyhqicb6cvr1dbjvkt |
| 259 | foreign key (policy_model_type, policy_model_version) |
| 260 | references policy_models (policy_model_type, version); |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 261 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 262 | alter table operational_policies |
| 263 | add constraint FKi9kh7my40737xeuaye9xwbnko |
| 264 | foreign key (loop_element_model_id) |
| 265 | references loop_element_models (name); |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 266 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 267 | alter table operational_policies |
| 268 | add constraint FKlsyhfkoqvkwj78ofepxhoctip |
| 269 | foreign key (policy_model_type, policy_model_version) |
| 270 | references policy_models (policy_model_type, version); |
sebdet | 93b4fd4 | 2020-03-25 09:19:34 -0700 | [diff] [blame] | 271 | |
saul.gill | 6238df4 | 2021-09-21 15:09:55 +0100 | [diff] [blame] | 272 | alter table operational_policies |
| 273 | add constraint FK1ddoggk9ni2bnqighv6ecmuwu |
| 274 | foreign key (loop_id) |
| 275 | references loops (name); |