|
1
|
use socle ;
|
|
2
|
-- DROP TABLES
|
|
3
|
DROP TABLE IF EXISTS solution_report_criterias_charts;
|
|
4
|
DROP TABLE IF EXISTS solution_report_criterias_config;
|
|
5
|
DROP TABLE IF EXISTS solution_report_charts;
|
|
6
|
DROP TABLE IF EXISTS solution_report_criterias;
|
|
7
|
DROP TABLE IF EXISTS company_reports_details;
|
|
8
|
DROP TABLE IF EXISTS company_reports;
|
|
9
|
DROP TABLE IF EXISTS solution_reports_config_gaps;
|
|
10
|
|
|
11
|
-- ===============================================
|
|
12
|
-- 1️ solution_reports_config_gaps
|
|
13
|
-- ===============================================
|
|
14
|
CREATE TABLE solution_reports_config_gaps (
|
|
15
|
subscription_code VARCHAR(255) NOT NULL,
|
|
16
|
category ENUM('market', 'personalized', 'matricule') NOT NULL,
|
|
17
|
gap BOOLEAN NOT NULL,
|
|
18
|
PRIMARY KEY (subscription_code, category),
|
|
19
|
FOREIGN KEY (subscription_code) REFERENCES solution_subscription(subscription_code)
|
|
20
|
ON DELETE CASCADE ON UPDATE CASCADE
|
|
21
|
);
|
|
22
|
|
|
23
|
INSERT INTO solution_reports_config_gaps (subscription_code, category, gap) VALUES
|
|
24
|
('essential', 'market', false),
|
|
25
|
('advanced', 'market', false),
|
|
26
|
('advanced', 'personalized', true),
|
|
27
|
('advanced', 'matricule', true),
|
|
28
|
('on_the_menu', 'market', false),
|
|
29
|
('on_the_menu', 'personalized', true),
|
|
30
|
('on_the_menu', 'matricule', true);
|
|
31
|
|
|
32
|
-- ===============================================
|
|
33
|
-- 2️ :solution_report_criterias
|
|
34
|
-- ===============================================
|
|
35
|
CREATE TABLE solution_report_criterias (
|
|
36
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
37
|
subscription_code VARCHAR(255) NOT NULL,
|
|
38
|
category ENUM('market', 'personalized', 'matricule') NOT NULL,
|
|
39
|
report_criterias VARCHAR(255) NOT NULL,
|
|
40
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
41
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
42
|
FOREIGN KEY (subscription_code, category)
|
|
43
|
REFERENCES solution_reports_config_gaps(subscription_code, category)
|
|
44
|
ON DELETE CASCADE ON UPDATE CASCADE,
|
|
45
|
UNIQUE KEY unique_report_per_subscription (subscription_code, category, report_criterias)
|
|
46
|
);
|
|
47
|
|
|
48
|
INSERT INTO solution_report_criterias (subscription_code, category, report_criterias) VALUES
|
|
49
|
-- Essential / market
|
|
50
|
('essential', 'market', 'essential-grade'),
|
|
51
|
('essential', 'market', 'essential-collaborative_path'),
|
|
52
|
('essential', 'market', 'essential-function_code-subfunction_code-collaborative_path'),
|
|
53
|
('essential', 'market', 'essential-function_code-subfunction_code-collaborative_path-grade'),
|
|
54
|
|
|
55
|
-- On The Menu / market
|
|
56
|
('on_the_menu', 'market', 'on_the_menu-grade'),
|
|
57
|
('on_the_menu', 'market', 'on_the_menu-collaborative_path'),
|
|
58
|
('on_the_menu', 'market', 'on_the_menu-function_code-subfunction_code-collaborative_path'),
|
|
59
|
('on_the_menu', 'market', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade'),
|
|
60
|
|
|
61
|
-- On The Menu / matricule
|
|
62
|
('on_the_menu', 'matricule', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade'),
|
|
63
|
|
|
64
|
-- On The Menu / personalized
|
|
65
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code'),
|
|
66
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path'),
|
|
67
|
('on_the_menu', 'personalized', 'on_the_menu-collaborative_path'),
|
|
68
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade'),
|
|
69
|
|
|
70
|
-- Advanced / market
|
|
71
|
('advanced', 'market', 'advanced-grade'),
|
|
72
|
('advanced', 'market', 'advanced-collaborative_path'),
|
|
73
|
('advanced', 'market', 'advanced-function_code-subfunction_code-collaborative_path'),
|
|
74
|
('advanced', 'market', 'advanced-function_code-subfunction_code-collaborative_path-grade'),
|
|
75
|
|
|
76
|
-- Advanced / matricule
|
|
77
|
('advanced', 'matricule', 'advanced-function_code-subfunction_code-collaborative_path-grade'),
|
|
78
|
|
|
79
|
-- Advanced / personalized
|
|
80
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code'),
|
|
81
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path'),
|
|
82
|
('advanced', 'personalized', 'advanced-collaborative_path'),
|
|
83
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path-grade');
|
|
84
|
|
|
85
|
|
|
86
|
|
|
87
|
-- ===============================================
|
|
88
|
-- 3️: solution_report_criterias_config
|
|
89
|
-- ===============================================
|
|
90
|
CREATE TABLE solution_report_criterias_config (
|
|
91
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
92
|
subscription_code VARCHAR(255) NOT NULL,
|
|
93
|
category ENUM('market', 'personalized', 'matricule') NOT NULL,
|
|
94
|
report_criterias VARCHAR(255) NOT NULL,
|
|
95
|
criteria VARCHAR(255) NOT NULL,
|
|
96
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
97
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
98
|
FOREIGN KEY (subscription_code, category, report_criterias)
|
|
99
|
REFERENCES solution_report_criterias(subscription_code, category, report_criterias)
|
|
100
|
ON DELETE CASCADE
|
|
101
|
ON UPDATE CASCADE
|
|
102
|
);
|
|
103
|
|
|
104
|
INSERT INTO solution_report_criterias_config
|
|
105
|
(subscription_code, category, report_criterias, criteria)
|
|
106
|
VALUES
|
|
107
|
-- Essential / market
|
|
108
|
('essential', 'market', 'essential-grade', 'grade'),
|
|
109
|
('essential', 'market', 'essential-collaborative_path', 'collaborative_path'),
|
|
110
|
('essential', 'market', 'essential-function_code-subfunction_code-collaborative_path', 'function_code'),
|
|
111
|
('essential', 'market', 'essential-function_code-subfunction_code-collaborative_path', 'subfunction_code'),
|
|
112
|
('essential', 'market', 'essential-function_code-subfunction_code-collaborative_path', 'collaborative_path'),
|
|
113
|
('essential', 'market', 'essential-function_code-subfunction_code-collaborative_path-grade', 'function_code'),
|
|
114
|
('essential', 'market', 'essential-function_code-subfunction_code-collaborative_path-grade', 'subfunction_code'),
|
|
115
|
('essential', 'market', 'essential-function_code-subfunction_code-collaborative_path-grade', 'collaborative_path'),
|
|
116
|
('essential', 'market', 'essential-function_code-subfunction_code-collaborative_path-grade', 'grade'),
|
|
117
|
|
|
118
|
-- On The Menu / market
|
|
119
|
('on_the_menu', 'market', 'on_the_menu-grade', 'grade'),
|
|
120
|
('on_the_menu', 'market', 'on_the_menu-collaborative_path', 'collaborative_path'),
|
|
121
|
('on_the_menu', 'market', 'on_the_menu-function_code-subfunction_code-collaborative_path', 'function_code'),
|
|
122
|
('on_the_menu', 'market', 'on_the_menu-function_code-subfunction_code-collaborative_path', 'subfunction_code'),
|
|
123
|
('on_the_menu', 'market', 'on_the_menu-function_code-subfunction_code-collaborative_path', 'collaborative_path'),
|
|
124
|
('on_the_menu', 'market', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'function_code'),
|
|
125
|
('on_the_menu', 'market', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'subfunction_code'),
|
|
126
|
('on_the_menu', 'market', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'collaborative_path'),
|
|
127
|
('on_the_menu', 'market', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'grade'),
|
|
128
|
|
|
129
|
-- On The Menu / matricule
|
|
130
|
('on_the_menu', 'matricule', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'function_code'),
|
|
131
|
('on_the_menu', 'matricule', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'subfunction_code'),
|
|
132
|
('on_the_menu', 'matricule', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'collaborative_path'),
|
|
133
|
('on_the_menu', 'matricule', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'grade'),
|
|
134
|
|
|
135
|
|
|
136
|
-- On The Menu / personalized
|
|
137
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code', 'function_code'),
|
|
138
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code', 'subfunction_code'),
|
|
139
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path', 'function_code'),
|
|
140
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path', 'subfunction_code'),
|
|
141
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path', 'collaborative_path'),
|
|
142
|
('on_the_menu', 'personalized', 'on_the_menu-collaborative_path', 'collaborative_path'),
|
|
143
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'function_code'),
|
|
144
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'subfunction_code'),
|
|
145
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'collaborative_path'),
|
|
146
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'grade'),
|
|
147
|
|
|
148
|
-- Advanced / market
|
|
149
|
('advanced', 'market', 'advanced-grade', 'grade'),
|
|
150
|
('advanced', 'market', 'advanced-collaborative_path', 'collaborative_path'),
|
|
151
|
('advanced', 'market', 'advanced-function_code-subfunction_code-collaborative_path', 'function_code'),
|
|
152
|
('advanced', 'market', 'advanced-function_code-subfunction_code-collaborative_path', 'subfunction_code'),
|
|
153
|
('advanced', 'market', 'advanced-function_code-subfunction_code-collaborative_path', 'collaborative_path'),
|
|
154
|
('advanced', 'market', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'function_code'),
|
|
155
|
('advanced', 'market', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'subfunction_code'),
|
|
156
|
('advanced', 'market', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'collaborative_path'),
|
|
157
|
('advanced', 'market', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'grade'),
|
|
158
|
|
|
159
|
-- Advanced / matricule
|
|
160
|
('advanced', 'matricule', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'function_code'),
|
|
161
|
('advanced', 'matricule', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'subfunction_code'),
|
|
162
|
('advanced', 'matricule', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'collaborative_path'),
|
|
163
|
('advanced', 'matricule', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'grade'),
|
|
164
|
|
|
165
|
|
|
166
|
-- Advanced / personalized
|
|
167
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code', 'function_code'),
|
|
168
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code', 'subfunction_code'),
|
|
169
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path', 'function_code'),
|
|
170
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path', 'subfunction_code'),
|
|
171
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path', 'collaborative_path'),
|
|
172
|
('advanced', 'personalized', 'advanced-collaborative_path', 'collaborative_path'),
|
|
173
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'function_code'),
|
|
174
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'subfunction_code'),
|
|
175
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'collaborative_path'),
|
|
176
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'grade');
|
|
177
|
|
|
178
|
|
|
179
|
|
|
180
|
-- ===============================================
|
|
181
|
-- 4 : solution_report_charts
|
|
182
|
-- ===============================================
|
|
183
|
CREATE TABLE solution_report_charts (
|
|
184
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
185
|
subscription_code VARCHAR(255) NOT NULL,
|
|
186
|
category ENUM('market', 'personalized', 'matricule') NOT NULL,
|
|
187
|
report_chart VARCHAR(255) NOT NULL,
|
|
188
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
189
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
190
|
FOREIGN KEY (subscription_code, category)
|
|
191
|
REFERENCES solution_reports_config_gaps(subscription_code, category)
|
|
192
|
ON DELETE CASCADE ON UPDATE CASCADE
|
|
193
|
);
|
|
194
|
|
|
195
|
INSERT INTO solution_report_charts (subscription_code, category, report_chart) VALUES
|
|
196
|
-- Essential / market
|
|
197
|
-- no graphs
|
|
198
|
|
|
199
|
-- On The Menu
|
|
200
|
-- no graphs for market category
|
|
201
|
|
|
202
|
|
|
203
|
('on_the_menu', 'matricule', 'gap_general'),
|
|
204
|
('on_the_menu', 'matricule', 'general_internal_gap_fixed'),
|
|
205
|
|
|
206
|
('on_the_menu', 'personalized', 'gap_general'),
|
|
207
|
('on_the_menu', 'personalized', 'general_internal_gap_fixed'),
|
|
208
|
|
|
209
|
-- Advanced
|
|
210
|
-- no graphs for market category
|
|
211
|
|
|
212
|
('advanced', 'matricule', 'gap_general'),
|
|
213
|
('advanced', 'matricule', 'general_internal_gap_fixed'),
|
|
214
|
|
|
215
|
('advanced', 'personalized', 'gap_general'),
|
|
216
|
('advanced', 'personalized', 'general_internal_gap_fixed');
|
|
217
|
|
|
218
|
|
|
219
|
-- ===============================================
|
|
220
|
-- 5️: solution_report_criterias_charts
|
|
221
|
-- ===============================================
|
|
222
|
CREATE TABLE solution_report_criterias_charts (
|
|
223
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
224
|
subscription_code VARCHAR(255) NOT NULL,
|
|
225
|
category ENUM('market', 'personalized', 'matricule') NOT NULL,
|
|
226
|
report_criterias VARCHAR(255) NOT NULL,
|
|
227
|
criteria VARCHAR(255) NOT NULL,
|
|
228
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
229
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
230
|
FOREIGN KEY (subscription_code, category, report_criterias)
|
|
231
|
REFERENCES solution_report_criterias(subscription_code, category, report_criterias)
|
|
232
|
ON DELETE CASCADE
|
|
233
|
ON UPDATE CASCADE
|
|
234
|
);
|
|
235
|
|
|
236
|
-- done
|
|
237
|
INSERT INTO solution_report_criterias_charts
|
|
238
|
(subscription_code, category, report_criterias, criteria) VALUES
|
|
239
|
-- On The Menu / personalized
|
|
240
|
('on_the_menu', 'personalized', 'on_the_menu-collaborative_path', 'repartition_gap'),
|
|
241
|
('on_the_menu', 'personalized', 'on_the_menu-collaborative_path', 'repartition_data_bf'),
|
|
242
|
('on_the_menu', 'personalized', 'on_the_menu-collaborative_path', 'repartition_data_bt'),
|
|
243
|
|
|
244
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code', 'repartition_gap'),
|
|
245
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code', 'repartition_data_bf'),
|
|
246
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code', 'repartition_data_bt'),
|
|
247
|
|
|
248
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path', 'repartition_gap'),
|
|
249
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path', 'repartition_data_bf'),
|
|
250
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path', 'repartition_data_bt'),
|
|
251
|
|
|
252
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'repartition_gap'),
|
|
253
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'repartition_data_bf'),
|
|
254
|
('on_the_menu', 'personalized', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'repartition_data_bt'),
|
|
255
|
|
|
256
|
-- On The Menu / matricule
|
|
257
|
('on_the_menu', 'matricule', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'repartition_gap'),
|
|
258
|
('on_the_menu', 'matricule', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'repartition_data_bf'),
|
|
259
|
('on_the_menu', 'matricule', 'on_the_menu-function_code-subfunction_code-collaborative_path-grade', 'repartition_data_bt'),
|
|
260
|
|
|
261
|
-- Advanced / matricule
|
|
262
|
('advanced', 'matricule', 'advanced-function_code-subfunction_code-collaborative_path-grade','repartition_gap'),
|
|
263
|
('advanced', 'matricule', 'advanced-function_code-subfunction_code-collaborative_path-grade','repartition_data_bf'),
|
|
264
|
('advanced', 'matricule', 'advanced-function_code-subfunction_code-collaborative_path-grade','repartition_data_bt'),
|
|
265
|
|
|
266
|
-- Advanced / personalized
|
|
267
|
('advanced', 'personalized', 'advanced-collaborative_path', 'repartition_gap'),
|
|
268
|
('advanced', 'personalized', 'advanced-collaborative_path', 'repartition_data_bf'),
|
|
269
|
('advanced', 'personalized', 'advanced-collaborative_path', 'repartition_data_bt'),
|
|
270
|
|
|
271
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code', 'repartition_gap'),
|
|
272
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code', 'repartition_data_bf'),
|
|
273
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code', 'repartition_data_bt'),
|
|
274
|
|
|
275
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path', 'repartition_gap'),
|
|
276
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path', 'repartition_data_bf'),
|
|
277
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path', 'repartition_data_bt'),
|
|
278
|
|
|
279
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'repartition_gap'),
|
|
280
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'repartition_data_bf'),
|
|
281
|
('advanced', 'personalized', 'advanced-function_code-subfunction_code-collaborative_path-grade', 'repartition_data_bt');
|
|
282
|
|
|
283
|
-- ===============================================
|
|
284
|
-- 6️: solution_report_calculation_columns + solution_report_display_columns
|
|
285
|
-- ===============================================
|
|
286
|
CREATE TABLE solution_report_calculation_columns (
|
|
287
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
288
|
subscription_code VARCHAR(255) NOT NULL,
|
|
289
|
category ENUM('market', 'personalized', 'matricule') NOT NULL,
|
|
290
|
column_name VARCHAR(255) NOT NULL,
|
|
291
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
292
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
293
|
FOREIGN KEY (subscription_code, category)
|
|
294
|
REFERENCES solution_reports_config_gaps(subscription_code, category)
|
|
295
|
ON DELETE CASCADE ON UPDATE CASCADE,
|
|
296
|
UNIQUE KEY unique_calc_col (subscription_code, category, column_name)
|
|
297
|
);
|
|
298
|
|
|
299
|
CREATE TABLE solution_report_display_columns (
|
|
300
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
301
|
subscription_code VARCHAR(255) NOT NULL,
|
|
302
|
category ENUM('market', 'personalized', 'matricule') NOT NULL,
|
|
303
|
column_name VARCHAR(255) NOT NULL,
|
|
304
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
305
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
306
|
FOREIGN KEY (subscription_code, category)
|
|
307
|
REFERENCES solution_reports_config_gaps(subscription_code, category)
|
|
308
|
ON DELETE CASCADE ON UPDATE CASCADE,
|
|
309
|
UNIQUE KEY unique_display_col (subscription_code, category, column_name)
|
|
310
|
);
|
|
311
|
|
|
312
|
-- On The Menu / matricule
|
|
313
|
INSERT INTO solution_report_calculation_columns (subscription_code, category, column_name) VALUES
|
|
314
|
('on_the_menu', 'matricule', 'matricule');
|
|
315
|
|
|
316
|
INSERT INTO solution_report_display_columns (subscription_code, category, column_name) VALUES
|
|
317
|
('on_the_menu', 'matricule', 'matricule'),
|
|
318
|
('on_the_menu', 'matricule', 'department'),
|
|
319
|
('on_the_menu', 'matricule', 'function');
|
|
320
|
|
|
321
|
-- Advanced / matricule
|
|
322
|
INSERT INTO solution_report_calculation_columns (subscription_code, category, column_name) VALUES
|
|
323
|
('advanced', 'matricule', 'matricule');
|
|
324
|
|
|
325
|
INSERT INTO solution_report_display_columns (subscription_code, category, column_name) VALUES
|
|
326
|
('advanced', 'matricule', 'matricule'),
|
|
327
|
('advanced', 'matricule', 'department'),
|
|
328
|
('advanced', 'matricule', 'function');
|
|
329
|
|
|
330
|
-- ===============================================
|
|
331
|
-- 7️: company_reports + company_reports_details
|
|
332
|
-- ===============================================
|
|
333
|
CREATE TABLE company_reports (
|
|
334
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
335
|
title VARCHAR(255) NOT NULL,
|
|
336
|
description TEXT,
|
|
337
|
report_type VARCHAR(20) NULL,
|
|
338
|
includeCompany BOOLEAN DEFAULT FALSE,
|
|
339
|
category ENUM('market', 'personalized', 'matricule') NOT NULL,
|
|
340
|
subscription_code VARCHAR(255) NOT NULL,
|
|
341
|
companyId INT NOT NULL,
|
|
342
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
343
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
344
|
FOREIGN KEY (companyId) REFERENCES company(id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
345
|
FOREIGN KEY (subscription_code, category)
|
|
346
|
REFERENCES solution_reports_config_gaps(subscription_code, category)
|
|
347
|
ON DELETE CASCADE ON UPDATE CASCADE
|
|
348
|
);
|
|
349
|
|
|
350
|
CREATE TABLE company_reports_details (
|
|
351
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
352
|
reportId INT NOT NULL,
|
|
353
|
request JSON NULL,
|
|
354
|
response JSON NULL,
|
|
355
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
356
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
357
|
FOREIGN KEY (reportId) REFERENCES company_reports(id)
|
|
358
|
ON DELETE CASCADE ON UPDATE CASCADE
|
|
359
|
);
|