Determe, Sebastien (sd378r) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 1 | # |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 2 | # Create CLDS database objects (tables, etc.) |
| 3 | # |
| 4 | # |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 5 | CREATE DATABASE `cldsdb4`; |
Determe, Sebastien (sd378r) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 6 | USE `cldsdb4`; |
| 7 | DROP USER 'clds'; |
| 8 | CREATE USER 'clds'; |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 9 | GRANT ALL on cldsdb4.* to 'clds' identified by 'sidnnd83K' with GRANT OPTION; |
| 10 | GRANT SELECT on mysql.proc TO 'clds'; |
| 11 | FLUSH PRIVILEGES; |
| 12 | |
| 13 | |
| 14 | CREATE 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 | |
| 24 | CREATE 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) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 28 | user_id VARCHAR(80), |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 29 | 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 | |
| 33 | CREATE 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) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 37 | user_id VARCHAR(80), |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 38 | 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 | |
| 42 | CREATE 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) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 46 | user_id VARCHAR(80), |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 47 | 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 | |
| 51 | CREATE 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) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 60 | service_type_id VARCHAR(80) NULL, |
| 61 | deployment_id VARCHAR(80) NULL, |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 62 | PRIMARY KEY (model_id), |
| 63 | UNIQUE (model_name), |
Determe, Sebastien (sd378r) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 64 | UNIQUE (control_name_uuid), |
| 65 | UNIQUE (service_type_id), |
| 66 | UNIQUE (deployment_id) |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 67 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 68 | |
| 69 | CREATE TABLE model_properties ( |
| 70 | model_prop_id VARCHAR(36) NOT NULL, |
| 71 | model_id VARCHAR(36) NOT NULL, |
| 72 | model_prop_text MEDIUMTEXT NULL, |
Determe, Sebastien (sd378r) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 73 | user_id VARCHAR(80), |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 74 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 75 | PRIMARY KEY (model_prop_id) |
| 76 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 77 | |
| 78 | CREATE TABLE model_blueprint ( |
| 79 | model_blueprint_id VARCHAR(36) NOT NULL, |
| 80 | model_id VARCHAR(36) NOT NULL, |
| 81 | model_blueprint_text MEDIUMTEXT NULL, |
Determe, Sebastien (sd378r) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 82 | user_id VARCHAR(80), |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 83 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 84 | PRIMARY KEY (model_blueprint_id) |
| 85 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 86 | |
| 87 | CREATE TABLE model_instance ( |
| 88 | model_instance_id VARCHAR(36) NOT NULL, |
| 89 | model_id VARCHAR(36) NOT NULL, |
| 90 | vm_name VARCHAR(250) NOT NULL, |
| 91 | location VARCHAR(250) NULL, |
| 92 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 93 | PRIMARY KEY (model_instance_id), |
| 94 | UNIQUE (model_id, vm_name) |
| 95 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 96 | |
| 97 | CREATE TABLE event ( |
| 98 | event_id VARCHAR(36) NOT NULL, |
| 99 | model_id VARCHAR(36) NULL, |
| 100 | action_cd VARCHAR(80) NOT NULL, |
| 101 | action_state_cd VARCHAR(80) NULL, |
| 102 | prev_event_id VARCHAR(36) NULL, |
| 103 | process_instance_id VARCHAR(80) NULL, |
Determe, Sebastien (sd378r) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 104 | user_id VARCHAR(80) NULL, |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 105 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, |
| 106 | PRIMARY KEY (event_id) |
| 107 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 108 | |
| 109 | CREATE TABLE clds_service_cache ( |
| 110 | invariant_service_id VARCHAR(36) NOT NULL, |
| 111 | service_id VARCHAR(36) NULL, |
| 112 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, |
| 113 | object_data MEDIUMBLOB NULL, |
| 114 | PRIMARY KEY (invariant_service_id) |
| 115 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 116 | |
sebdet | 6651e17 | 2018-09-03 14:39:21 +0200 | [diff] [blame^] | 117 | CREATE TABLE IF NOT EXISTS tosca_model ( |
| 118 | tosca_model_id VARCHAR(36) NOT NULL, |
| 119 | tosca_model_name VARCHAR(80) NOT NULL, |
| 120 | policy_type VARCHAR(80) NULL, |
| 121 | user_id VARCHAR(80), |
| 122 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 123 | PRIMARY KEY (tosca_model_id) |
| 124 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 125 | |
| 126 | CREATE TABLE IF NOT EXISTS tosca_model_revision ( |
| 127 | tosca_model_revision_id VARCHAR(36) NOT NULL, |
| 128 | tosca_model_id VARCHAR(36) NOT NULL, |
| 129 | version DOUBLE NOT NULL DEFAULT 1, |
| 130 | tosca_model_yaml MEDIUMTEXT NULL, |
| 131 | tosca_model_json MEDIUMTEXT NULL, |
| 132 | user_id VARCHAR(80), |
| 133 | createdTimestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, |
| 134 | lastUpdatedTimestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 135 | PRIMARY KEY (tosca_model_revision_id), |
| 136 | CONSTRAINT tosca_model_revision_ukey UNIQUE KEY (tosca_model_id, version), |
| 137 | CONSTRAINT tosca_model_revision_fkey01 FOREIGN KEY (tosca_model_id) REFERENCES tosca_model (tosca_model_id) |
| 138 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 139 | |
| 140 | CREATE TABLE IF NOT EXISTS dictionary ( |
| 141 | dictionary_id VARCHAR(36) NOT NULL, |
| 142 | dictionary_name VARCHAR(80) NOT NULL, |
| 143 | created_by VARCHAR(80), |
| 144 | modified_by VARCHAR(80), |
| 145 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 146 | PRIMARY KEY (dictionary_id) |
| 147 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 148 | |
| 149 | CREATE TABLE IF NOT EXISTS dictionary_elements ( |
| 150 | dict_element_id VARCHAR(36) NOT NULL, |
| 151 | dictionary_id VARCHAR(36) NOT NULL, |
| 152 | dict_element_name VARCHAR(250) NOT NULL, |
| 153 | dict_element_short_name VARCHAR(80) NOT NULL, |
| 154 | dict_element_description VARCHAR(250), |
| 155 | dict_element_type VARCHAR(80) NOT NULL, |
| 156 | created_by VARCHAR(80), |
| 157 | modified_by VARCHAR(80), |
| 158 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 159 | PRIMARY KEY (dict_element_id), |
| 160 | CONSTRAINT dictionary_elements_ukey UNIQUE KEY (dict_element_name, dict_element_short_name), |
| 161 | CONSTRAINT dictionary_elements_ukey_fkey01 FOREIGN KEY (dictionary_id) REFERENCES dictionary (dictionary_id) |
| 162 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 163 | |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 164 | ALTER TABLE template |
| 165 | ADD CONSTRAINT template_bpmn_id_fkey01 |
| 166 | FOREIGN KEY (template_bpmn_id) |
| 167 | REFERENCES template_bpmn (template_bpmn_id); |
| 168 | |
| 169 | ALTER TABLE template |
| 170 | ADD CONSTRAINT template_image_id_fkey01 |
| 171 | FOREIGN KEY (template_image_id) |
| 172 | REFERENCES template_image (template_image_id); |
| 173 | |
| 174 | ALTER TABLE template |
| 175 | ADD CONSTRAINT template_doc_id_fkey01 |
| 176 | FOREIGN KEY (template_doc_id) |
| 177 | REFERENCES template_doc (template_doc_id); |
Determe, Sebastien (sd378r) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 178 | |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 179 | ALTER TABLE template_bpmn |
| 180 | ADD CONSTRAINT template_id_fkey02 |
| 181 | FOREIGN KEY (template_id) |
| 182 | REFERENCES template (template_id); |
| 183 | |
| 184 | ALTER TABLE template_image |
| 185 | ADD CONSTRAINT template_id_fkey03 |
| 186 | FOREIGN KEY (template_id) |
| 187 | REFERENCES template (template_id); |
| 188 | |
| 189 | ALTER TABLE template_doc |
| 190 | ADD CONSTRAINT template_id_fkey04 |
| 191 | FOREIGN KEY (template_id) |
Determe, Sebastien (sd378r) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 192 | REFERENCES template (template_id); |
| 193 | |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 194 | ALTER TABLE model |
| 195 | ADD CONSTRAINT template_id_fkey01 |
| 196 | FOREIGN KEY (template_id) |
| 197 | REFERENCES template (template_id); |
| 198 | |
| 199 | ALTER TABLE model |
| 200 | ADD CONSTRAINT model_prop_id_fkey01 |
| 201 | FOREIGN KEY (model_prop_id) |
| 202 | REFERENCES model_properties (model_prop_id); |
| 203 | |
| 204 | ALTER TABLE model |
| 205 | ADD CONSTRAINT model_blueprint_id_fkey01 |
| 206 | FOREIGN KEY (model_blueprint_id) |
| 207 | REFERENCES model_blueprint (model_blueprint_id); |
Determe, Sebastien (sd378r) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 208 | |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 209 | ALTER TABLE model |
| 210 | ADD CONSTRAINT event_id_fkey01 |
| 211 | FOREIGN KEY (event_id) |
| 212 | REFERENCES event (event_id); |
| 213 | |
| 214 | ALTER TABLE model_properties |
| 215 | ADD CONSTRAINT model_id_fkey01 |
| 216 | FOREIGN KEY (model_id) |
Determe, Sebastien (sd378r) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 217 | REFERENCES model (model_id); |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 218 | |
| 219 | ALTER TABLE model_blueprint |
| 220 | ADD CONSTRAINT model_id_fkey02 |
| 221 | FOREIGN KEY (model_id) |
Determe, Sebastien (sd378r) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 222 | REFERENCES model (model_id); |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 223 | |
| 224 | ALTER TABLE model_instance |
| 225 | ADD CONSTRAINT model_id_fkey04 |
| 226 | FOREIGN KEY (model_id) |
Determe, Sebastien (sd378r) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 227 | REFERENCES model (model_id); |
| 228 | |
ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame] | 229 | ALTER TABLE event |
| 230 | ADD CONSTRAINT model_id_fkey03 |
| 231 | FOREIGN KEY (model_id) |
Determe, Sebastien (sd378r) | b3a21f7 | 2017-08-08 02:58:27 -0700 | [diff] [blame] | 232 | REFERENCES model (model_id); |