forked from zammad/zammad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20120101000010_create_ticket.rb
614 lines (577 loc) · 32.4 KB
/
20120101000010_create_ticket.rb
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
# Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
class CreateTicket < ActiveRecord::Migration[4.2]
def up
create_table :ticket_state_types do |t|
t.column :name, :string, limit: 250, null: false
t.column :note, :string, limit: 250, null: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :ticket_state_types, [:name], unique: true
add_foreign_key :ticket_state_types, :users, column: :created_by_id
add_foreign_key :ticket_state_types, :users, column: :updated_by_id
create_table :ticket_states do |t|
t.references :state_type, null: false
t.column :name, :string, limit: 250, null: false
t.column :next_state_id, :integer, null: true
t.column :ignore_escalation, :boolean, null: false, default: false
t.column :default_create, :boolean, null: false, default: false
t.column :default_follow_up, :boolean, null: false, default: false
t.column :note, :string, limit: 250, null: true
t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :ticket_states, [:name], unique: true
add_index :ticket_states, [:default_create]
add_index :ticket_states, [:default_follow_up]
add_foreign_key :ticket_states, :ticket_state_types, column: :state_type_id
add_foreign_key :ticket_states, :users, column: :created_by_id
add_foreign_key :ticket_states, :users, column: :updated_by_id
create_table :ticket_priorities do |t|
t.column :name, :string, limit: 250, null: false
t.column :default_create, :boolean, null: false, default: false
t.column :ui_icon, :string, limit: 100, null: true
t.column :ui_color, :string, limit: 100, null: true
t.column :note, :string, limit: 250, null: true
t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :ticket_priorities, [:name], unique: true
add_index :ticket_priorities, [:default_create]
add_foreign_key :ticket_priorities, :users, column: :created_by_id
add_foreign_key :ticket_priorities, :users, column: :updated_by_id
create_table :tickets do |t|
t.references :group, null: false
t.references :priority, null: false
t.references :state, null: false
t.references :organization, null: true
t.column :number, :string, limit: 60, null: false
t.column :title, :string, limit: 250, null: false
t.column :owner_id, :integer, null: false
t.column :customer_id, :integer, null: false
t.column :note, :string, limit: 250, null: true
t.column :first_response_at, :timestamp, limit: 3, null: true
t.column :first_response_escalation_at, :timestamp, limit: 3, null: true
t.column :first_response_in_min, :integer, null: true
t.column :first_response_diff_in_min, :integer, null: true
t.column :close_at, :timestamp, limit: 3, null: true
t.column :close_escalation_at, :timestamp, limit: 3, null: true
t.column :close_in_min, :integer, null: true
t.column :close_diff_in_min, :integer, null: true
t.column :update_escalation_at, :timestamp, limit: 3, null: true
t.column :update_in_min, :integer, null: true
t.column :update_diff_in_min, :integer, null: true
t.column :last_close_at, :timestamp, limit: 3, null: true
t.column :last_contact_at, :timestamp, limit: 3, null: true
t.column :last_contact_agent_at, :timestamp, limit: 3, null: true
t.column :last_contact_customer_at, :timestamp, limit: 3, null: true
t.column :last_owner_update_at, :timestamp, limit: 3, null: true
t.column :create_article_type_id, :integer, null: true
t.column :create_article_sender_id, :integer, null: true
t.column :article_count, :integer, null: true
t.column :escalation_at, :timestamp, limit: 3, null: true
t.column :pending_time, :timestamp, limit: 3, null: true
t.column :type, :string, limit: 100, null: true
t.column :time_unit, :decimal, precision: 6, scale: 2, null: true
t.column :preferences, :text, limit: 500.kilobytes + 1, null: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :tickets, [:state_id]
add_index :tickets, [:priority_id]
add_index :tickets, [:group_id]
add_index :tickets, [:owner_id]
add_index :tickets, [:customer_id]
add_index :tickets, %i[customer_id state_id created_at]
add_index :tickets, [:number], unique: true
add_index :tickets, [:title]
add_index :tickets, [:created_at]
add_index :tickets, [:updated_at]
add_index :tickets, [:first_response_at]
add_index :tickets, [:first_response_escalation_at]
add_index :tickets, [:first_response_in_min]
add_index :tickets, [:first_response_diff_in_min]
add_index :tickets, [:close_at]
add_index :tickets, [:close_escalation_at]
add_index :tickets, [:close_in_min]
add_index :tickets, [:close_diff_in_min]
add_index :tickets, [:escalation_at]
add_index :tickets, [:update_in_min]
add_index :tickets, [:update_diff_in_min]
add_index :tickets, [:last_contact_at]
add_index :tickets, [:last_contact_agent_at]
add_index :tickets, [:last_contact_customer_at]
add_index :tickets, [:last_owner_update_at]
add_index :tickets, [:create_article_type_id]
add_index :tickets, [:create_article_sender_id]
add_index :tickets, [:created_by_id]
add_index :tickets, [:pending_time]
add_index :tickets, [:type]
add_index :tickets, [:time_unit]
add_index :tickets, %i[group_id state_id]
add_index :tickets, %i[group_id state_id owner_id]
add_index :tickets, %i[group_id state_id updated_at]
add_index :tickets, %i[group_id state_id owner_id updated_at], name: 'index_tickets_on_group_id_state_id_owner_id_updated_at'
add_index :tickets, %i[group_id state_id created_at]
add_index :tickets, %i[group_id state_id owner_id created_at], name: 'index_tickets_on_group_id_state_id_owner_id_created_at'
add_index :tickets, %i[group_id state_id close_at]
add_index :tickets, %i[group_id state_id owner_id close_at], name: 'index_tickets_on_group_id_state_id_owner_id_close_at'
add_foreign_key :tickets, :groups
add_foreign_key :tickets, :users, column: :owner_id
add_foreign_key :tickets, :users, column: :customer_id
add_foreign_key :tickets, :ticket_priorities, column: :priority_id
add_foreign_key :tickets, :ticket_states, column: :state_id
add_foreign_key :tickets, :organizations
add_foreign_key :tickets, :users, column: :created_by_id
add_foreign_key :tickets, :users, column: :updated_by_id
create_table :ticket_flags do |t|
t.references :ticket, null: false
t.column :key, :string, limit: 50, null: false
t.column :value, :string, limit: 50, null: true
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :ticket_flags, %i[ticket_id created_by_id]
add_index :ticket_flags, %i[ticket_id key]
add_index :ticket_flags, [:ticket_id]
add_index :ticket_flags, [:created_by_id]
add_foreign_key :ticket_flags, :tickets, column: :ticket_id
add_foreign_key :ticket_flags, :users, column: :created_by_id
create_table :ticket_article_types do |t|
t.column :name, :string, limit: 250, null: false
t.column :note, :string, limit: 250, null: true
t.column :communication, :boolean, null: false, default: false
t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :ticket_article_types, [:name], unique: true
add_foreign_key :ticket_article_types, :users, column: :created_by_id
add_foreign_key :ticket_article_types, :users, column: :updated_by_id
create_table :ticket_article_senders do |t|
t.column :name, :string, limit: 250, null: false
t.column :note, :string, limit: 250, null: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :ticket_article_senders, [:name], unique: true
add_foreign_key :ticket_article_senders, :users, column: :created_by_id
add_foreign_key :ticket_article_senders, :users, column: :updated_by_id
create_table :ticket_articles do |t|
t.references :ticket, null: false
t.references :type, null: false
t.references :sender, null: false
t.column :from, :string, limit: 3000, null: true
t.column :to, :string, limit: 3000, null: true
t.column :cc, :string, limit: 3000, null: true
t.column :subject, :string, limit: 3000, null: true
t.column :reply_to, :string, limit: 300, null: true
t.column :message_id, :string, limit: 3000, null: true
t.column :message_id_md5, :string, limit: 32, null: true
t.column :in_reply_to, :string, limit: 3000, null: true
t.column :content_type, :string, limit: 20, null: false, default: 'text/plain'
t.column :references, :string, limit: 3200, null: true
t.column :body, :text, limit: 20.megabytes + 1, null: false
t.column :internal, :boolean, null: false, default: false
t.column :preferences, :text, limit: 500.kilobytes + 1, null: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.column :origin_by_id, :integer
t.timestamps limit: 3, null: false
end
add_index :ticket_articles, [:ticket_id]
add_index :ticket_articles, [:message_id_md5]
add_index :ticket_articles, %i[message_id_md5 type_id], name: 'index_ticket_articles_message_id_md5_type_id'
add_index :ticket_articles, [:created_by_id]
add_index :ticket_articles, [:created_at]
add_index :ticket_articles, [:internal]
add_index :ticket_articles, [:type_id]
add_index :ticket_articles, [:sender_id]
add_foreign_key :ticket_articles, :tickets
add_foreign_key :ticket_articles, :ticket_article_types, column: :type_id
add_foreign_key :ticket_articles, :ticket_article_senders, column: :sender_id
add_foreign_key :ticket_articles, :users, column: :created_by_id
add_foreign_key :ticket_articles, :users, column: :updated_by_id
add_foreign_key :ticket_articles, :users, column: :origin_by_id
create_table :ticket_article_flags do |t|
t.references :ticket_article, null: false
t.column :key, :string, limit: 50, null: false
t.column :value, :string, limit: 50, null: true
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :ticket_article_flags, %i[ticket_article_id created_by_id], name: 'index_ticket_article_flags_on_articles_id_and_created_by_id'
add_index :ticket_article_flags, %i[ticket_article_id key]
add_index :ticket_article_flags, [:ticket_article_id]
add_index :ticket_article_flags, [:created_by_id]
add_foreign_key :ticket_article_flags, :ticket_articles, column: :ticket_article_id
add_foreign_key :ticket_article_flags, :users, column: :created_by_id
create_table :ticket_time_accountings do |t|
t.references :ticket, null: false
t.references :ticket_article, null: true
t.column :time_unit, :decimal, precision: 6, scale: 2, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :ticket_time_accountings, [:ticket_id]
add_index :ticket_time_accountings, [:ticket_article_id]
add_index :ticket_time_accountings, [:created_by_id]
add_index :ticket_time_accountings, [:time_unit]
add_foreign_key :ticket_time_accountings, :tickets
add_foreign_key :ticket_time_accountings, :ticket_articles
add_foreign_key :ticket_time_accountings, :users, column: :created_by_id
create_table :ticket_counters do |t|
t.column :content, :string, limit: 100, null: false
t.column :generator, :string, limit: 100, null: false
end
add_index :ticket_counters, [:generator], unique: true
create_table :overviews do |t|
t.column :name, :string, limit: 250, null: false
t.column :link, :string, limit: 250, null: false
t.column :prio, :integer, null: false
t.column :condition, :text, limit: 500.kilobytes + 1, null: false
t.column :order, :string, limit: 2500, null: false
t.column :group_by, :string, limit: 250, null: true
t.column :group_direction, :string, limit: 250, null: true
t.column :organization_shared, :boolean, null: false, default: false
t.column :out_of_office, :boolean, null: false, default: false
t.column :view, :string, limit: 1000, null: false
t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :overviews, [:name]
add_foreign_key :overviews, :users, column: :created_by_id
add_foreign_key :overviews, :users, column: :updated_by_id
create_table :overviews_roles, id: false do |t|
t.references :overview
t.references :role
end
add_index :overviews_roles, [:overview_id]
add_index :overviews_roles, [:role_id]
add_foreign_key :overviews_roles, :overviews
add_foreign_key :overviews_roles, :roles
create_table :overviews_users, id: false do |t|
t.references :overview
t.references :user
end
add_index :overviews_users, [:overview_id]
add_index :overviews_users, [:user_id]
add_foreign_key :overviews_users, :overviews
add_foreign_key :overviews_users, :users
create_table :overviews_groups, id: false do |t|
t.references :overview
t.references :group
end
add_index :overviews_groups, [:overview_id]
add_index :overviews_groups, [:group_id]
add_foreign_key :overviews_groups, :overviews
add_foreign_key :overviews_groups, :groups
create_table :triggers do |t|
t.column :name, :string, limit: 250, null: false
t.column :condition, :text, limit: 500.kilobytes + 1, null: false
t.column :perform, :text, limit: 500.kilobytes + 1, null: false
t.column :disable_notification, :boolean, null: false, default: true
t.column :note, :string, limit: 250, null: true
t.column :activator, :string, limit: 50, null: false, default: 'action'
t.column :execution_condition_mode, :string, limit: 50, null: false, default: 'selective'
t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :triggers, [:name], unique: true
add_index :triggers, %i[active activator]
add_foreign_key :triggers, :users, column: :created_by_id
add_foreign_key :triggers, :users, column: :updated_by_id
create_table :jobs do |t|
t.column :name, :string, limit: 250, null: false
t.column :timeplan, :string, limit: 2500, null: false
t.column :condition, :text, limit: 500.kilobytes + 1, null: false
t.column :perform, :text, limit: 500.kilobytes + 1, null: false
t.column :disable_notification, :boolean, null: false, default: true
t.column :last_run_at, :timestamp, limit: 3, null: true
t.column :next_run_at, :timestamp, limit: 3, null: true
t.column :running, :boolean, null: false, default: false
t.column :processed, :integer, null: false, default: 0
t.column :matching, :integer, null: false
t.column :pid, :string, limit: 250, null: true
t.column :note, :string, limit: 250, null: true
t.column :active, :boolean, null: false, default: false
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :jobs, [:name], unique: true
add_foreign_key :jobs, :users, column: :created_by_id
add_foreign_key :jobs, :users, column: :updated_by_id
create_table :link_types do |t|
t.column :name, :string, limit: 250, null: false
t.column :note, :string, limit: 250, null: true
t.column :active, :boolean, null: false, default: true
t.timestamps limit: 3, null: false
end
add_index :link_types, [:name], unique: true
create_table :link_objects do |t|
t.column :name, :string, limit: 250, null: false
t.column :note, :string, limit: 250, null: true
t.column :active, :boolean, null: false, default: true
t.timestamps limit: 3, null: false
end
add_index :link_objects, [:name], unique: true
create_table :links do |t|
t.references :link_type, null: false
t.column :link_object_source_id, :integer, null: false
t.column :link_object_source_value, :integer, null: false
t.column :link_object_target_id, :integer, null: false
t.column :link_object_target_value, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :links, %i[link_object_source_id link_object_source_value link_object_target_id link_object_target_value link_type_id], unique: true, name: 'links_uniq_total'
add_foreign_key :links, :link_types
create_table :postmaster_filters do |t|
t.column :name, :string, limit: 250, null: false
t.column :channel, :string, limit: 250, null: false
t.column :match, :text, limit: 500.kilobytes + 1, null: false
t.column :perform, :text, limit: 500.kilobytes + 1, null: false
t.column :active, :boolean, null: false, default: true
t.column :note, :string, limit: 250, null: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :postmaster_filters, [:channel]
add_foreign_key :postmaster_filters, :users, column: :created_by_id
add_foreign_key :postmaster_filters, :users, column: :updated_by_id
create_table :text_modules do |t|
t.column :name, :string, limit: 250, null: false
t.column :keywords, :string, limit: 500, null: true
t.column :content, :text, limit: 10.megabytes + 1, null: false
t.column :note, :string, limit: 250, null: true
t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :text_modules, [:name]
add_foreign_key :text_modules, :users, column: :created_by_id
add_foreign_key :text_modules, :users, column: :updated_by_id
create_table :text_modules_groups, id: false do |t|
t.references :text_module
t.references :group
end
add_index :text_modules_groups, [:text_module_id]
add_index :text_modules_groups, [:group_id]
add_foreign_key :text_modules_groups, :text_modules
add_foreign_key :text_modules_groups, :groups
create_table :templates do |t|
t.column :name, :string, limit: 250, null: false
t.column :options, :text, limit: 10.megabytes + 1, null: false
t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :templates, [:name]
add_foreign_key :templates, :users, column: :created_by_id
add_foreign_key :templates, :users, column: :updated_by_id
create_table :templates_groups, id: false do |t|
t.references :template
t.references :group
end
add_index :templates_groups, [:template_id]
add_index :templates_groups, [:group_id]
add_foreign_key :templates_groups, :templates
add_foreign_key :templates_groups, :groups
create_table :channels do |t|
t.references :group, null: true
t.column :area, :string, limit: 100, null: false
t.column :options, :text, limit: 500.kilobytes + 1, null: true
t.column :active, :boolean, null: false, default: true
t.column :preferences, :string, limit: 2000, null: true
t.column :last_log_in, :text, limit: 500.kilobytes + 1, null: true
t.column :last_log_out, :text, limit: 500.kilobytes + 1, null: true
t.column :status_in, :string, limit: 100, null: true
t.column :status_out, :string, limit: 100, null: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :channels, [:area]
add_foreign_key :channels, :groups
add_foreign_key :channels, :users, column: :created_by_id
add_foreign_key :channels, :users, column: :updated_by_id
create_table :slas do |t|
t.references :calendar, null: false
t.column :name, :string, limit: 150, null: true
t.column :first_response_time, :integer, null: true
t.column :response_time, :integer, null: true
t.column :update_time, :integer, null: true
t.column :solution_time, :integer, null: true
t.column :condition, :text, limit: 500.kilobytes + 1, null: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :slas, [:name], unique: true
add_foreign_key :slas, :users, column: :created_by_id
add_foreign_key :slas, :users, column: :updated_by_id
create_table :macros do |t|
t.string :name, limit: 250, null: true
t.text :perform, limit: 500.kilobytes + 1, null: false
t.boolean :active, null: false, default: true
t.string :ux_flow_next_up, null: false, default: 'none'
t.string :note, limit: 250, null: true
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps limit: 3, null: false
end
add_index :macros, [:name], unique: true
add_foreign_key :macros, :users, column: :created_by_id
add_foreign_key :macros, :users, column: :updated_by_id
create_table :chats do |t|
t.string :name, limit: 250, null: true
t.integer :max_queue, null: false, default: 5
t.string :note, limit: 250, null: true
t.boolean :active, null: false, default: true
t.boolean :public, null: false, default: false
t.string :block_ip, limit: 5000, null: true
t.string :block_country, limit: 5000, null: true
t.string :allowed_websites, limit: 5000, null: true
t.string :preferences, limit: 5000, null: true
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps limit: 3, null: false
end
add_index :chats, [:name], unique: true
add_foreign_key :chats, :users, column: :created_by_id
add_foreign_key :chats, :users, column: :updated_by_id
create_table :chat_sessions do |t|
t.references :chat, null: false
t.string :session_id, null: false
t.string :name, limit: 250, null: true
t.string :state, limit: 50, null: false, default: 'waiting' # running, closed
t.references :user, null: true
t.text :preferences, limit: 100.kilobytes + 1, null: true
t.integer :updated_by_id, null: true
t.integer :created_by_id, null: true
t.timestamps limit: 3, null: false
end
add_index :chat_sessions, [:session_id]
add_index :chat_sessions, [:state]
add_index :chat_sessions, [:user_id]
add_index :chat_sessions, [:chat_id]
add_foreign_key :chat_sessions, :chats
add_foreign_key :chat_sessions, :users
add_foreign_key :chat_sessions, :users, column: :created_by_id
add_foreign_key :chat_sessions, :users, column: :updated_by_id
create_table :chat_messages do |t|
t.references :chat_session, null: false
t.text :content, limit: 20.megabytes + 1, null: false
t.integer :created_by_id, null: true
t.timestamps limit: 3, null: false
end
add_index :chat_messages, [:chat_session_id]
add_foreign_key :chat_messages, :chat_sessions
add_foreign_key :chat_messages, :users, column: :created_by_id
create_table :chat_agents do |t|
t.boolean :active, null: false, default: true
t.integer :concurrent, null: false, default: 5
t.integer :updated_by_id, null: false
t.integer :created_by_id, null: false
t.timestamps limit: 3, null: false
end
add_index :chat_agents, [:active]
add_index :chat_agents, [:updated_by_id], unique: true
add_index :chat_agents, [:created_by_id], unique: true
add_foreign_key :chat_agents, :users, column: :created_by_id
add_foreign_key :chat_agents, :users, column: :updated_by_id
create_table :report_profiles do |t|
t.column :name, :string, limit: 150, null: true
t.column :condition, :text, limit: 500.kilobytes + 1, null: true
t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
add_index :report_profiles, [:name], unique: true
add_foreign_key :report_profiles, :users, column: :created_by_id
add_foreign_key :report_profiles, :users, column: :updated_by_id
create_table :webhooks do |t|
t.column :name, :string, limit: 250, null: false
t.column :endpoint, :string, limit: 300, null: false
t.column :signature_token, :string, limit: 200, null: true
t.column :ssl_verify, :boolean, null: false, default: true
t.column :basic_auth_username, :string, limit: 250, null: true
t.column :basic_auth_password, :string, limit: 250, null: true
t.column :note, :string, limit: 500, null: true
t.column :pre_defined_webhook_type, :string, limit: 250, null: true
t.column :customized_payload, :boolean, null: false, default: false
t.column :custom_payload, :text, limit: 500.kilobytes + 1, null: true
t.column :preferences, :text, limit: 500.kilobytes + 1, null: true
t.column :active, :boolean, null: false, default: true
t.column :updated_by_id, :integer, null: false
t.column :created_by_id, :integer, null: false
t.timestamps limit: 3, null: false
end
create_table :ticket_shared_draft_zooms do |t|
t.references :ticket, null: false, foreign_key: { to_table: :tickets }
t.text :new_article
t.text :ticket_attributes
t.column :created_by_id, :integer, null: false
t.column :updated_by_id, :integer, null: false
t.timestamps limit: 3
end
create_table :ticket_shared_draft_starts do |t|
t.references :group, null: false, foreign_key: { to_table: :groups }
t.string :name
t.text :content
t.column :created_by_id, :integer, null: false
t.column :updated_by_id, :integer, null: false
t.timestamps limit: 3
end
end
def self.down
drop_table :report_profiles
drop_table :chat_sessions
drop_table :chat_messages
drop_table :chat_agents
drop_table :chats
drop_table :macros
drop_table :slas
drop_table :channels
drop_table :templates_groups
drop_table :templates
drop_table :text_modules_groups
drop_table :text_modules
drop_table :postmaster_filters
drop_table :triggers
drop_table :links
drop_table :link_types
drop_table :link_objects
drop_table :overviews
drop_table :ticket_counters
drop_table :ticket_time_accounting
drop_table :ticket_article_flags
drop_table :ticket_articles
drop_table :ticket_article_types
drop_table :ticket_article_senders
drop_table :ticket_flags
drop_table :tickets
drop_table :ticket_priorities
drop_table :ticket_states
drop_table :ticket_state_types
drop_table :webhooks
drop_table :ticket_shared_draft_zooms
drop_table :ticket_shared_draft_starts
end
end