ChrisC | 5e9feb2 | 2017-06-21 02:38:57 -0700 | [diff] [blame^] | 1 | # |
| 2 | # Create CLDS database objects (tables, etc.) |
| 3 | # |
| 4 | # |
| 5 | CREATE DATABASE `camundabpm`; |
| 6 | USE `camundabpm`; |
| 7 | DROP USER 'camunda'; |
| 8 | CREATE USER 'camunda'; |
| 9 | GRANT ALL on camundabpm.* to 'camunda' identified by 'ndMSpw4CAM' with GRANT OPTION; |
| 10 | FLUSH PRIVILEGES; |
| 11 | |
| 12 | CREATE DATABASE `cldsdb4`; |
| 13 | USE `cldsdb4`; |
| 14 | DROP USER 'clds'; |
| 15 | CREATE USER 'clds'; |
| 16 | GRANT ALL on cldsdb4.* to 'clds' identified by 'sidnnd83K' with GRANT OPTION; |
| 17 | GRANT SELECT on mysql.proc TO 'clds'; |
| 18 | FLUSH PRIVILEGES; |
| 19 | |
| 20 | |
| 21 | CREATE TABLE template ( |
| 22 | template_id VARCHAR(36) NOT NULL, |
| 23 | template_name VARCHAR(80) NOT NULL, |
| 24 | template_bpmn_id VARCHAR(36) NULL, |
| 25 | template_image_id VARCHAR(36) NULL, |
| 26 | template_doc_id VARCHAR(36) NULL, |
| 27 | PRIMARY KEY (template_id), |
| 28 | UNIQUE (template_name) |
| 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 30 | |
| 31 | CREATE TABLE template_bpmn ( |
| 32 | template_bpmn_id VARCHAR(36) NOT NULL, |
| 33 | template_id VARCHAR(36) NOT NULL, |
| 34 | template_bpmn_text MEDIUMTEXT NOT NULL, |
| 35 | userid VARCHAR(8), |
| 36 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 37 | PRIMARY KEY (template_bpmn_id) |
| 38 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 39 | |
| 40 | CREATE TABLE template_image ( |
| 41 | template_image_id VARCHAR(36) NOT NULL, |
| 42 | template_id VARCHAR(36) NOT NULL, |
| 43 | template_image_text MEDIUMTEXT NULL, |
| 44 | userid VARCHAR(8), |
| 45 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 46 | PRIMARY KEY (template_image_id) |
| 47 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 48 | |
| 49 | CREATE TABLE template_doc ( |
| 50 | template_doc_id VARCHAR(36) NOT NULL, |
| 51 | template_id VARCHAR(36) NOT NULL, |
| 52 | template_doc_text MEDIUMTEXT NULL, |
| 53 | userid VARCHAR(8), |
| 54 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 55 | PRIMARY KEY (template_doc_id) |
| 56 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 57 | |
| 58 | CREATE TABLE model ( |
| 59 | model_id VARCHAR(36) NOT NULL, |
| 60 | model_name VARCHAR(80) NOT NULL, |
| 61 | template_id VARCHAR(36) NULL, |
| 62 | model_prop_id VARCHAR(36) NULL, |
| 63 | model_blueprint_id VARCHAR(36) NULL, |
| 64 | event_id VARCHAR(36) NULL, |
| 65 | control_name_prefix VARCHAR(80) NULL, |
| 66 | control_name_uuid VARCHAR(36) NOT NULL, |
| 67 | PRIMARY KEY (model_id), |
| 68 | UNIQUE (model_name), |
| 69 | UNIQUE (control_name_uuid) |
| 70 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 71 | |
| 72 | CREATE TABLE model_properties ( |
| 73 | model_prop_id VARCHAR(36) NOT NULL, |
| 74 | model_id VARCHAR(36) NOT NULL, |
| 75 | model_prop_text MEDIUMTEXT NULL, |
| 76 | userid VARCHAR(8), |
| 77 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 78 | PRIMARY KEY (model_prop_id) |
| 79 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 80 | |
| 81 | CREATE TABLE model_blueprint ( |
| 82 | model_blueprint_id VARCHAR(36) NOT NULL, |
| 83 | model_id VARCHAR(36) NOT NULL, |
| 84 | model_blueprint_text MEDIUMTEXT NULL, |
| 85 | userid VARCHAR(8), |
| 86 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 87 | PRIMARY KEY (model_blueprint_id) |
| 88 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 89 | |
| 90 | CREATE TABLE model_instance ( |
| 91 | model_instance_id VARCHAR(36) NOT NULL, |
| 92 | model_id VARCHAR(36) NOT NULL, |
| 93 | vm_name VARCHAR(250) NOT NULL, |
| 94 | location VARCHAR(250) NULL, |
| 95 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| 96 | PRIMARY KEY (model_instance_id), |
| 97 | UNIQUE (model_id, vm_name) |
| 98 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 99 | |
| 100 | CREATE TABLE event ( |
| 101 | event_id VARCHAR(36) NOT NULL, |
| 102 | model_id VARCHAR(36) NULL, |
| 103 | action_cd VARCHAR(80) NOT NULL, |
| 104 | action_state_cd VARCHAR(80) NULL, |
| 105 | prev_event_id VARCHAR(36) NULL, |
| 106 | process_instance_id VARCHAR(80) NULL, |
| 107 | userid VARCHAR(8) NULL, |
| 108 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, |
| 109 | PRIMARY KEY (event_id) |
| 110 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 111 | |
| 112 | CREATE TABLE clds_service_cache ( |
| 113 | invariant_service_id VARCHAR(36) NOT NULL, |
| 114 | service_id VARCHAR(36) NULL, |
| 115 | timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, |
| 116 | object_data MEDIUMBLOB NULL, |
| 117 | PRIMARY KEY (invariant_service_id) |
| 118 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin; |
| 119 | |
| 120 | ALTER TABLE template |
| 121 | ADD CONSTRAINT template_bpmn_id_fkey01 |
| 122 | FOREIGN KEY (template_bpmn_id) |
| 123 | REFERENCES template_bpmn (template_bpmn_id); |
| 124 | |
| 125 | ALTER TABLE template |
| 126 | ADD CONSTRAINT template_image_id_fkey01 |
| 127 | FOREIGN KEY (template_image_id) |
| 128 | REFERENCES template_image (template_image_id); |
| 129 | |
| 130 | ALTER TABLE template |
| 131 | ADD CONSTRAINT template_doc_id_fkey01 |
| 132 | FOREIGN KEY (template_doc_id) |
| 133 | REFERENCES template_doc (template_doc_id); |
| 134 | |
| 135 | ALTER TABLE template_bpmn |
| 136 | ADD CONSTRAINT template_id_fkey02 |
| 137 | FOREIGN KEY (template_id) |
| 138 | REFERENCES template (template_id); |
| 139 | |
| 140 | ALTER TABLE template_image |
| 141 | ADD CONSTRAINT template_id_fkey03 |
| 142 | FOREIGN KEY (template_id) |
| 143 | REFERENCES template (template_id); |
| 144 | |
| 145 | ALTER TABLE template_doc |
| 146 | ADD CONSTRAINT template_id_fkey04 |
| 147 | FOREIGN KEY (template_id) |
| 148 | REFERENCES template (template_id); |
| 149 | |
| 150 | ALTER TABLE model |
| 151 | ADD CONSTRAINT template_id_fkey01 |
| 152 | FOREIGN KEY (template_id) |
| 153 | REFERENCES template (template_id); |
| 154 | |
| 155 | ALTER TABLE model |
| 156 | ADD CONSTRAINT model_prop_id_fkey01 |
| 157 | FOREIGN KEY (model_prop_id) |
| 158 | REFERENCES model_properties (model_prop_id); |
| 159 | |
| 160 | ALTER TABLE model |
| 161 | ADD CONSTRAINT model_blueprint_id_fkey01 |
| 162 | FOREIGN KEY (model_blueprint_id) |
| 163 | REFERENCES model_blueprint (model_blueprint_id); |
| 164 | |
| 165 | ALTER TABLE model |
| 166 | ADD CONSTRAINT event_id_fkey01 |
| 167 | FOREIGN KEY (event_id) |
| 168 | REFERENCES event (event_id); |
| 169 | |
| 170 | ALTER TABLE model_properties |
| 171 | ADD CONSTRAINT model_id_fkey01 |
| 172 | FOREIGN KEY (model_id) |
| 173 | REFERENCES model (model_id); |
| 174 | |
| 175 | ALTER TABLE model_blueprint |
| 176 | ADD CONSTRAINT model_id_fkey02 |
| 177 | FOREIGN KEY (model_id) |
| 178 | REFERENCES model (model_id); |
| 179 | |
| 180 | ALTER TABLE model_instance |
| 181 | ADD CONSTRAINT model_id_fkey04 |
| 182 | FOREIGN KEY (model_id) |
| 183 | REFERENCES model (model_id); |
| 184 | |
| 185 | ALTER TABLE event |
| 186 | ADD CONSTRAINT model_id_fkey03 |
| 187 | FOREIGN KEY (model_id) |
| 188 | REFERENCES model (model_id); |
| 189 | |