blob: 5cbb7e01778ec5c0d5669914c8cf396397b91f5f [file] [log] [blame]
ChrisC5e9feb22017-06-21 02:38:57 -07001#
2# Create CLDS database objects (tables, etc.)
3#
4#
5CREATE DATABASE `camundabpm`;
6USE `camundabpm`;
7DROP USER 'camunda';
8CREATE USER 'camunda';
9GRANT ALL on camundabpm.* to 'camunda' identified by 'ndMSpw4CAM' with GRANT OPTION;
10FLUSH PRIVILEGES;
11
12CREATE DATABASE `cldsdb4`;
13USE `cldsdb4`;
14DROP USER 'clds';
15CREATE USER 'clds';
16GRANT ALL on cldsdb4.* to 'clds' identified by 'sidnnd83K' with GRANT OPTION;
17GRANT SELECT on mysql.proc TO 'clds';
18FLUSH PRIVILEGES;
19
20
21CREATE 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
31CREATE 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
40CREATE 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
49CREATE 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
58CREATE 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
72CREATE 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
81CREATE 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
90CREATE 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
100CREATE 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
112CREATE 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
120ALTER TABLE template
121 ADD CONSTRAINT template_bpmn_id_fkey01
122 FOREIGN KEY (template_bpmn_id)
123 REFERENCES template_bpmn (template_bpmn_id);
124
125ALTER TABLE template
126 ADD CONSTRAINT template_image_id_fkey01
127 FOREIGN KEY (template_image_id)
128 REFERENCES template_image (template_image_id);
129
130ALTER TABLE template
131 ADD CONSTRAINT template_doc_id_fkey01
132 FOREIGN KEY (template_doc_id)
133 REFERENCES template_doc (template_doc_id);
134
135ALTER TABLE template_bpmn
136 ADD CONSTRAINT template_id_fkey02
137 FOREIGN KEY (template_id)
138 REFERENCES template (template_id);
139
140ALTER TABLE template_image
141 ADD CONSTRAINT template_id_fkey03
142 FOREIGN KEY (template_id)
143 REFERENCES template (template_id);
144
145ALTER TABLE template_doc
146 ADD CONSTRAINT template_id_fkey04
147 FOREIGN KEY (template_id)
148 REFERENCES template (template_id);
149
150ALTER TABLE model
151 ADD CONSTRAINT template_id_fkey01
152 FOREIGN KEY (template_id)
153 REFERENCES template (template_id);
154
155ALTER TABLE model
156 ADD CONSTRAINT model_prop_id_fkey01
157 FOREIGN KEY (model_prop_id)
158 REFERENCES model_properties (model_prop_id);
159
160ALTER TABLE model
161 ADD CONSTRAINT model_blueprint_id_fkey01
162 FOREIGN KEY (model_blueprint_id)
163 REFERENCES model_blueprint (model_blueprint_id);
164
165ALTER TABLE model
166 ADD CONSTRAINT event_id_fkey01
167 FOREIGN KEY (event_id)
168 REFERENCES event (event_id);
169
170ALTER TABLE model_properties
171 ADD CONSTRAINT model_id_fkey01
172 FOREIGN KEY (model_id)
173 REFERENCES model (model_id);
174
175ALTER TABLE model_blueprint
176 ADD CONSTRAINT model_id_fkey02
177 FOREIGN KEY (model_id)
178 REFERENCES model (model_id);
179
180ALTER TABLE model_instance
181 ADD CONSTRAINT model_id_fkey04
182 FOREIGN KEY (model_id)
183 REFERENCES model (model_id);
184
185ALTER TABLE event
186 ADD CONSTRAINT model_id_fkey03
187 FOREIGN KEY (model_id)
188 REFERENCES model (model_id);
189