-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtechfixDB.sql
More file actions
348 lines (329 loc) · 18.8 KB
/
techfixDB.sql
File metadata and controls
348 lines (329 loc) · 18.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
create table techfix_chat_message
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
content text null,
role varchar(255) not null,
user_id binary(16) not null,
image_url longtext null
)
engine = InnoDB;
create table techfix_client
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
address varchar(255) not null,
code varchar(255) not null,
first_name varchar(255) not null,
last_interaction datetime(6) null,
last_name varchar(255) not null,
legal_type enum ('PARTICULAR', 'PROFESSIONAL', 'ORGANIZATION', 'GOVERNMENT') not null,
loyalty_points int not null,
notes text null,
phone_number1 varchar(255) not null,
phone_number2 varchar(255) null,
preferred_contact enum ('EMAIL', 'PHONE', 'SMS') default 'EMAIL' not null,
sentiment_score float null,
tax_number varchar(255) null,
email varchar(255) null,
company_id binary(16) not null,
workshop_id binary(16) not null,
constraint UKa7shm927ox1coqsb9dsmlicgb
unique (code),
constraint FK6c0dxn09ki9vvpdnhe8x1c8ys
foreign key (workshop_id) references techfix_workshop (id),
constraint FKe4r0vi6h8xhgc9p7xjqkrw0e4
foreign key (company_id) references techfix_company (id)
)
engine = InnoDB;
create table techfix_company
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
contact_email varchar(255) not null,
industry varchar(255) null,
legal_signature varchar(255) null,
logo_path varchar(255) null,
name varchar(255) not null,
phone_number varchar(255) not null,
tva varchar(255) null,
website varchar(255) null,
address varchar(255) not null,
stamp_path varchar(255) null,
tax_number varchar(255) not null,
timezone varchar(255) not null
)
engine = InnoDB;
create table techfix_invoice
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
amount decimal(10, 2) not null,
discount decimal(10, 2) not null,
due_date date not null,
invoice_number varchar(255) not null,
notes text null,
payment_terms varchar(255) not null,
status enum ('DRAFT', 'PENDING', 'PARTIALLY_PAID', 'PAID', 'OVERDUE', 'CANCELLED', 'REFUNDED') not null,
tax decimal(10, 2) not null,
total decimal(10, 2) not null,
ticket_id binary(16) not null,
constraint UKbucwcnca8fjw5g2qfb2o4femq
unique (invoice_number),
constraint FKklw2c4p71te4qce90qd3h6hhp
foreign key (ticket_id) references techfix_ticket (id)
)
engine = InnoDB;
create table techfix_kpi_aggregations
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
average_repair_time double not null,
company_id binary(16) null,
in_progress_tickets bigint not null,
new_clients bigint not null,
returning_clients bigint not null,
tech_performance double not null,
tickets_per_hour bigint not null,
workshop_efficiency double not null,
workshop_id binary(16) null,
average_repair_time_for_tech double null,
average_repair_time_for_workshop double null,
average_tickets_per_tech double null,
completed_tickets bigint null,
completed_tickets_for_tech bigint null,
completion_ratio double null,
completion_ratio_for_tech double null,
completion_ratio_for_workshop double null,
tickets_last_hour bigint null
)
engine = InnoDB;
create table techfix_kpi_techs
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
average_repair_time double null,
completed_tickets bigint null,
completion_ratio double null,
tech_id binary(16) null,
kpi_aggregation_id binary(16) null,
constraint FKlje4lcy4r8gaiyevmslmniyfy
foreign key (kpi_aggregation_id) references techfix_kpi_aggregations (id)
)
engine = InnoDB;
create table techfix_kpi_workshops
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
average_repair_time double null,
completion_ratio double null,
workshop_id binary(16) null,
kpi_aggregation_id binary(16) null,
constraint FKtdix3xi6mqu9adqy2jqndcurt
foreign key (kpi_aggregation_id) references techfix_kpi_aggregations (id)
)
engine = InnoDB;
create table techfix_notifications
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
action_type enum ('ACKNOWLEDGE', 'CONFIRM_EMAIL_CLIENT', 'GENERATE_INVOICE', 'INFO_ONLY', 'OPEN_TICKET') not null,
is_read bit not null,
message text not null,
related_entity_id binary(16) null,
related_entity_type varchar(255) null,
title varchar(255) not null,
type enum ('ERROR', 'INFO', 'SUCCESS', 'WARNING') not null,
user_id binary(16) not null,
constraint FKbs45xfnrdu5eoap1c2gv8pemj
foreign key (user_id) references techfix_user (id)
)
engine = InnoDB;
create table techfix_payment
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
amount decimal(10, 2) not null,
method enum ('BANK_TRANSFER', 'CARD', 'CASH', 'OTHER') not null,
notes text null,
paid_date datetime(6) not null,
transaction_ref varchar(255) null,
invoice_id binary(16) not null,
constraint FKkc14238dwsetxbxofvp0jmgb9
foreign key (invoice_id) references techfix_invoice (id)
)
engine = InnoDB;
create table techfix_ticket
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
accessories text null,
actual_completion_date datetime(6) null,
actual_duration int null,
ai_diagnosis text null,
code varchar(255) not null,
designation varchar(255) not null,
device_model varchar(255) not null,
device_reference varchar(255) null,
device_status enum ('NEW', 'DAMAGED', 'USED') not null,
device_type enum ('PC', 'LAPTOP', 'MOBILE', 'TABLET', 'SERVER', 'NETWORK_EQUIPMENT', 'MEDICAL', 'PRINTER', 'AUDIO_VIDEO', 'APPLIANCE', 'OTHER') not null,
estimated_cost decimal(10, 2) null,
estimated_duration int null,
expected_completion_date datetime(6) null,
initial_diagnosis text null,
priority enum ('HIGH', 'LOW', 'MEDIUM', 'URGENT') not null,
problem_description text not null,
qr_code varchar(255) not null,
status enum ('TO_DO', 'DIAGNOSED', 'IN_PROGRESS', 'COMPLETED', 'BLOCKED', 'CLOSED', 'CANCELLED', 'AWAITING_PAYMENT', 'PAID') not null,
type enum ('CUSTOM_WORK', 'UPGRADE', 'INSPECTION', 'INSTALLATION', 'WARRANTY', 'MAINTENANCE') not null,
warranty_expiry date null,
assigned_tech_id binary(16) null,
client_id binary(16) not null,
workshop_id binary(16) not null,
total_cost decimal(38, 2) not null,
completed_at datetime(6) null,
constraint UKqghq0cyt8a2j6snuq9nff4v1g
unique (qr_code),
constraint UKqvg01guakxhywhjoirvx32uit
unique (code),
constraint FKhp20cafgrgkp1cm4wy70og3a
foreign key (workshop_id) references techfix_workshop (id),
constraint FKkp6gny2dphcgrpw6crjchx0tk
foreign key (client_id) references techfix_client (id),
constraint FKt4av8psw2o5wtqnwbn48amrip
foreign key (assigned_tech_id) references techfix_user (id)
)
engine = InnoDB;
create table techfix_ticket_line
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
description varchar(255) null,
name varchar(255) not null,
part_number varchar(255) null,
quantity decimal(10, 2) not null,
total_price decimal(10, 2) null,
type enum ('ITEM', 'PART') not null,
unit_price decimal(10, 2) null,
ticket_id binary(16) not null,
constraint FK4farh4criqt3vgmrwx6iq5w7l
foreign key (ticket_id) references techfix_ticket (id)
)
engine = InnoDB;
create table techfix_user
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
email varchar(255) not null,
first_name varchar(255) not null,
is_active bit not null,
last_login datetime(6) null,
last_name varchar(255) not null,
password varchar(255) not null,
phone_number1 varchar(255) not null,
phone_number2 varchar(255) null,
role enum ('ADMIN', 'CHEF', 'TECH') not null,
username varchar(255) not null,
workshop_id binary(16) null,
profile_image varchar(255) null,
company_id binary(16) null,
constraint UKeuo0cw7s8fos9wompvcqq8v9q
unique (username),
constraint UKo4mn24nk2mikqhijb2yjymv8v
unique (email),
constraint FK17m9yuf1m6q7x5oynrfs0kw09
foreign key (workshop_id) references techfix_workshop (id),
constraint FKek6nnn4mlnjwvft4m32f8q420
foreign key (company_id) references techfix_company (id)
on delete set null
)
engine = InnoDB;
create index idx_user_email
on techfix_user (email);
create index idx_user_username
on techfix_user (username);
create table techfix_work_session
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
end_time datetime(6) null,
start_time datetime(6) not null,
ticket_id binary(16) not null,
constraint FKoo3q0k9uy1n1731igl0fh76cy
foreign key (ticket_id) references techfix_ticket (id)
)
engine = InnoDB;
create table techfix_workshop
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
address varchar(255) not null,
business_hours text not null,
name varchar(255) not null,
signature_path varchar(255) null,
timezone varchar(255) not null,
company_id binary(16) not null,
contact_email varchar(255) not null,
phone_number varchar(255) not null,
constraint FK2xguted4oibrwrkrcp4cdr1gb
foreign key (company_id) references techfix_company (id)
)
engine = InnoDB;
create table ticket_attachments
(
id binary(16) not null
primary key,
created_at datetime(6) not null,
updated_at datetime(6) not null,
file_name varchar(255) null,
file_type varchar(255) not null,
file_url varchar(255) not null,
ticket_id binary(16) not null,
constraint FKtitir80lhp4jwvk0vc8vd4uga
foreign key (ticket_id) references techfix_ticket (id)
)
engine = InnoDB;
create table user_specialization
(
user_id binary(16) not null,
specialization varchar(255) null,
constraint FK6ds27k9tho2ogcq5858xvmi94
foreign key (user_id) references techfix_user (id)
)
engine = InnoDB;
create table workshop_services
(
workshop_id binary(16) not null,
services varchar(255) null,
constraint FKl3jpgxo8bgslfkdrt9c307hwt
foreign key (workshop_id) references techfix_workshop (id)
)
engine = InnoDB;