|
1
|
use socle;
|
|
2
|
|
|
3
|
CREATE TABLE company_reports (
|
|
4
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
5
|
title VARCHAR(255) NOT NULL,
|
|
6
|
description TEXT,
|
|
7
|
report_type VARCHAR(20) NULL,
|
|
8
|
companyId INT NOT NULL,
|
|
9
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
10
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
11
|
FOREIGN KEY (companyId) REFERENCES company(id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
12
|
);
|
|
13
|
|
|
14
|
CREATE TABLE company_reports_details (
|
|
15
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
16
|
reportId INT NOT NULL,
|
|
17
|
request_table JSON NULL,
|
|
18
|
request_chart JSON NULL,
|
|
19
|
response_table JSON NULL,
|
|
20
|
response_chart JSON NULL,
|
|
21
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
22
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
23
|
FOREIGN KEY (reportId) REFERENCES company_reports(id) ON DELETE CASCADE ON UPDATE CASCADE
|
|
24
|
);
|
|
25
|
|
|
26
|
CREATE TABLE solution_report_subscription (
|
|
27
|
id INT AUTO_INCREMENT UNIQUE,
|
|
28
|
report_code VARCHAR(255) PRIMARY KEY,
|
|
29
|
subscription_code VARCHAR(255),
|
|
30
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
31
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
32
|
FOREIGN KEY (subscription_code) REFERENCES solution_subscription(subscription_code) ON DELETE CASCADE ON UPDATE CASCADE
|
|
33
|
);
|
|
34
|
|
|
35
|
INSERT INTO solution_report_subscription (report_code, subscription_code) VALUES
|
|
36
|
-- Compensation
|
|
37
|
('report_essential_1', 'essential'),
|
|
38
|
('report_on_the_menu_1', 'on_the_menu'),
|
|
39
|
('report_advanced_1', 'advanced');
|
|
40
|
|
|
41
|
CREATE TABLE solution_report_criterias (
|
|
42
|
id INT AUTO_INCREMENT UNIQUE,
|
|
43
|
report_code VARCHAR(255) NOT NULL,
|
|
44
|
subscription VARCHAR(255) NOT NULL,
|
|
45
|
report_criterias VARCHAR(255) PRIMARY KEY,
|
|
46
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
47
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
48
|
FOREIGN KEY (report_code) REFERENCES solution_report_subscription(report_code) ON DELETE CASCADE ON UPDATE CASCADE
|
|
49
|
);
|
|
50
|
|
|
51
|
INSERT INTO solution_report_criterias (report_code, subscription, report_criterias) VALUES
|
|
52
|
-- Essential
|
|
53
|
('report_essential_1', 'essential', 'essential_1-grade'),
|
|
54
|
('report_essential_1', 'essential', 'essential_1-collaborative_path'),
|
|
55
|
('report_essential_1', 'essential', 'essential_1-function_code-subfunction_code-collaborative_path'),
|
|
56
|
('report_essential_1', 'essential', 'essential_1-function_code-subfunction_code-collaborative_path_grade'),
|
|
57
|
|
|
58
|
-- On The Menu
|
|
59
|
('report_on_the_menu_1', 'on_the_menu', 'on_the_menu_1-function_code-subfunction_code'),
|
|
60
|
('report_on_the_menu_1', 'on_the_menu', 'on_the_menu_1-function_code-subfunction_code-collaborative_path'),
|
|
61
|
('report_on_the_menu_1', 'on_the_menu', 'on_the_menu_1-collaborative_path'),
|
|
62
|
('report_on_the_menu_1' , 'on_the_menu', 'on_the_menu_1-function_code-subfunction_code-collaborative_path-grade'),
|
|
63
|
|
|
64
|
-- Advanced
|
|
65
|
('report_advanced_1', 'advanced', 'advanced_1-function_code-subfunction_code'),
|
|
66
|
('report_advanced_1', 'advanced', 'advanced_1-function_code-subfunction_code-collaborative_path'),
|
|
67
|
('report_advanced_1', 'advanced', 'advanced_1-collaborative_path'),
|
|
68
|
('report_advanced_1' , 'advanced', 'advanced_1-function_code-subfunction_code-collaborative_path-grade');
|
|
69
|
|
|
70
|
CREATE TABLE solution_report_criterias_config (
|
|
71
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
72
|
report_criterias VARCHAR(255) NOT NULL,
|
|
73
|
criteria VARCHAR(255) NOT NULL,
|
|
74
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
75
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
76
|
FOREIGN KEY (report_criterias) REFERENCES solution_report_criterias(report_criterias) ON DELETE CASCADE ON UPDATE CASCADE
|
|
77
|
);
|
|
78
|
|
|
79
|
INSERT INTO solution_report_criterias_config (report_criterias, criteria) VALUES
|
|
80
|
-- Essential
|
|
81
|
('essential_1-grade', 'grade'),
|
|
82
|
('essential_1-collaborative_path', 'collaborative_path'),
|
|
83
|
('essential_1-function_code-subfunction_code-collaborative_path', 'function_code'),
|
|
84
|
('essential_1-function_code-subfunction_code-collaborative_path', 'subfunction_code'),
|
|
85
|
('essential_1-function_code-subfunction_code-collaborative_path', 'collaborative_path'),
|
|
86
|
('essential_1-function_code-subfunction_code-collaborative_path_grade', 'function_code'),
|
|
87
|
('essential_1-function_code-subfunction_code-collaborative_path_grade', 'subfunction_code'),
|
|
88
|
('essential_1-function_code-subfunction_code-collaborative_path_grade', 'collaborative_path'),
|
|
89
|
('essential_1-function_code-subfunction_code-collaborative_path_grade', 'grade'),
|
|
90
|
|
|
91
|
-- On The Menu
|
|
92
|
('on_the_menu_1-function_code-subfunction_code', 'function_code'),
|
|
93
|
('on_the_menu_1-function_code-subfunction_code', 'subfunction_code'),
|
|
94
|
('on_the_menu_1-function_code-subfunction_code-collaborative_path', 'function_code'),
|
|
95
|
('on_the_menu_1-function_code-subfunction_code-collaborative_path', 'subfunction_code'),
|
|
96
|
('on_the_menu_1-function_code-subfunction_code-collaborative_path', 'collaborative_path'),
|
|
97
|
('on_the_menu_1-collaborative_path', 'collaborative_path'),
|
|
98
|
('on_the_menu_1-function_code-subfunction_code-collaborative_path-grade' , 'function_code'),
|
|
99
|
('on_the_menu_1-function_code-subfunction_code-collaborative_path-grade' , 'subfunction_code'),
|
|
100
|
('on_the_menu_1-function_code-subfunction_code-collaborative_path-grade' , 'collaborative_path'),
|
|
101
|
('on_the_menu_1-function_code-subfunction_code-collaborative_path-grade' , 'grade'),
|
|
102
|
|
|
103
|
-- Advanced
|
|
104
|
('advanced_1-function_code-subfunction_code', 'function_code'),
|
|
105
|
('advanced_1-function_code-subfunction_code', 'subfunction_code'),
|
|
106
|
('advanced_1-function_code-subfunction_code-collaborative_path', 'function_code'),
|
|
107
|
('advanced_1-function_code-subfunction_code-collaborative_path', 'subfunction_code'),
|
|
108
|
('advanced_1-function_code-subfunction_code-collaborative_path', 'collaborative_path'),
|
|
109
|
('advanced_1-collaborative_path', 'collaborative_path'),
|
|
110
|
('advanced_1-function_code-subfunction_code-collaborative_path-grade' , 'function_code'),
|
|
111
|
('advanced_1-function_code-subfunction_code-collaborative_path-grade' , 'subfunction_code'),
|
|
112
|
('advanced_1-function_code-subfunction_code-collaborative_path-grade' , 'collaborative_path'),
|
|
113
|
('advanced_1-function_code-subfunction_code-collaborative_path-grade' , 'grade');
|
|
114
|
|
|
115
|
CREATE TABLE solution_report_charts (
|
|
116
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
117
|
report_code VARCHAR(255) NOT NULL,
|
|
118
|
chart_code VARCHAR(255) NOT NULL,
|
|
119
|
subscription_code VARCHAR(255) NOT NULL,
|
|
120
|
createdAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
121
|
updatedAt TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
122
|
FOREIGN KEY (report_code) REFERENCES solution_report_subscription(report_code) ON DELETE CASCADE ON UPDATE CASCADE
|
|
123
|
);
|
|
124
|
|
|
125
|
INSERT INTO solution_report_charts (report_code, chart_code, subscription_code) VALUES
|
|
126
|
('report_essential_1', 'gap_general', 'essential'),
|
|
127
|
('report_on_the_menu_1', 'gap_general', 'on_the_menu'),
|
|
128
|
('report_on_the_menu_1', 'repartition_gap', 'on_the_menu'),
|
|
129
|
('report_on_the_menu_1', 'repartition_data_bf', 'on_the_menu'),
|
|
130
|
('report_on_the_menu_1', 'repartition_data_bt', 'on_the_menu'),
|
|
131
|
('report_on_the_menu_1', 'general_internal_gap_fixed', 'on_the_menu'),
|
|
132
|
('report_advanced_1', 'gap_general', 'advanced'),
|
|
133
|
('report_advanced_1', 'repartition_gap', 'advanced'),
|
|
134
|
('report_advanced_1', 'repartition_data_bf', 'advanced'),
|
|
135
|
('report_advanced_1', 'repartition_data_bt', 'advanced'),
|
|
136
|
('report_advanced_1', 'general_internal_gap_fixed', 'advanced');
|