This file is indexed.

/usr/share/otrs/scripts/database/otrs-schema-post.mysql.sql is in otrs2 6.0.5-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
# ----------------------------------------------------------
#  driver: mysql
# ----------------------------------------------------------
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'acl' AND constraint_name = 'FK_acl_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE acl ADD CONSTRAINT FK_acl_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_acl_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'acl' AND constraint_name = 'FK_acl_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE acl ADD CONSTRAINT FK_acl_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_acl_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'acl' AND constraint_name = 'FK_acl_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE acl ADD CONSTRAINT FK_acl_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_acl_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'valid' AND constraint_name = 'FK_valid_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE valid ADD CONSTRAINT FK_valid_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_valid_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'valid' AND constraint_name = 'FK_valid_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE valid ADD CONSTRAINT FK_valid_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_valid_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'users' AND constraint_name = 'FK_users_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE users ADD CONSTRAINT FK_users_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_users_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'users' AND constraint_name = 'FK_users_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE users ADD CONSTRAINT FK_users_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_users_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'users' AND constraint_name = 'FK_users_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE users ADD CONSTRAINT FK_users_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_users_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'user_preferences' AND constraint_name = 'FK_user_preferences_user_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE user_preferences ADD CONSTRAINT FK_user_preferences_user_id_id FOREIGN KEY (user_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_user_preferences_user_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'groups' AND constraint_name = 'FK_groups_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE groups ADD CONSTRAINT FK_groups_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_groups_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'groups' AND constraint_name = 'FK_groups_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE groups ADD CONSTRAINT FK_groups_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_groups_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'groups' AND constraint_name = 'FK_groups_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE groups ADD CONSTRAINT FK_groups_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_groups_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_user' AND constraint_name = 'FK_group_user_group_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_user ADD CONSTRAINT FK_group_user_group_id_id FOREIGN KEY (group_id) REFERENCES groups (id)', 'SELECT ''INFO: Foreign key constraint FK_group_user_group_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_user' AND constraint_name = 'FK_group_user_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_user ADD CONSTRAINT FK_group_user_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_group_user_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_user' AND constraint_name = 'FK_group_user_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_user ADD CONSTRAINT FK_group_user_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_group_user_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_user' AND constraint_name = 'FK_group_user_user_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_user ADD CONSTRAINT FK_group_user_user_id_id FOREIGN KEY (user_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_group_user_user_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_role' AND constraint_name = 'FK_group_role_group_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_role ADD CONSTRAINT FK_group_role_group_id_id FOREIGN KEY (group_id) REFERENCES groups (id)', 'SELECT ''INFO: Foreign key constraint FK_group_role_group_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_role' AND constraint_name = 'FK_group_role_role_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_role ADD CONSTRAINT FK_group_role_role_id_id FOREIGN KEY (role_id) REFERENCES roles (id)', 'SELECT ''INFO: Foreign key constraint FK_group_role_role_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_role' AND constraint_name = 'FK_group_role_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_role ADD CONSTRAINT FK_group_role_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_group_role_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_role' AND constraint_name = 'FK_group_role_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_role ADD CONSTRAINT FK_group_role_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_group_role_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_customer_user' AND constraint_name = 'FK_group_customer_user_group_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_customer_user ADD CONSTRAINT FK_group_customer_user_group_id_id FOREIGN KEY (group_id) REFERENCES groups (id)', 'SELECT ''INFO: Foreign key constraint FK_group_customer_user_group_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_customer_user' AND constraint_name = 'FK_group_customer_user_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_customer_user ADD CONSTRAINT FK_group_customer_user_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_group_customer_user_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_customer_user' AND constraint_name = 'FK_group_customer_user_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_customer_user ADD CONSTRAINT FK_group_customer_user_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_group_customer_user_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_customer' AND constraint_name = 'FK_group_customer_group_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_customer ADD CONSTRAINT FK_group_customer_group_id_id FOREIGN KEY (group_id) REFERENCES groups (id)', 'SELECT ''INFO: Foreign key constraint FK_group_customer_group_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_customer' AND constraint_name = 'FK_group_customer_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_customer ADD CONSTRAINT FK_group_customer_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_group_customer_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'group_customer' AND constraint_name = 'FK_group_customer_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE group_customer ADD CONSTRAINT FK_group_customer_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_group_customer_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'roles' AND constraint_name = 'FK_roles_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE roles ADD CONSTRAINT FK_roles_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_roles_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'roles' AND constraint_name = 'FK_roles_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE roles ADD CONSTRAINT FK_roles_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_roles_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'roles' AND constraint_name = 'FK_roles_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE roles ADD CONSTRAINT FK_roles_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_roles_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'role_user' AND constraint_name = 'FK_role_user_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE role_user ADD CONSTRAINT FK_role_user_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_role_user_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'role_user' AND constraint_name = 'FK_role_user_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE role_user ADD CONSTRAINT FK_role_user_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_role_user_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'role_user' AND constraint_name = 'FK_role_user_user_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE role_user ADD CONSTRAINT FK_role_user_user_id_id FOREIGN KEY (user_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_role_user_user_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'personal_queues' AND constraint_name = 'FK_personal_queues_queue_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE personal_queues ADD CONSTRAINT FK_personal_queues_queue_id_id FOREIGN KEY (queue_id) REFERENCES queue (id)', 'SELECT ''INFO: Foreign key constraint FK_personal_queues_queue_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'personal_queues' AND constraint_name = 'FK_personal_queues_user_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE personal_queues ADD CONSTRAINT FK_personal_queues_user_id_id FOREIGN KEY (user_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_personal_queues_user_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'personal_services' AND constraint_name = 'FK_personal_services_service_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE personal_services ADD CONSTRAINT FK_personal_services_service_id_id FOREIGN KEY (service_id) REFERENCES service (id)', 'SELECT ''INFO: Foreign key constraint FK_personal_services_service_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'personal_services' AND constraint_name = 'FK_personal_services_user_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE personal_services ADD CONSTRAINT FK_personal_services_user_id_id FOREIGN KEY (user_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_personal_services_user_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'salutation' AND constraint_name = 'FK_salutation_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE salutation ADD CONSTRAINT FK_salutation_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_salutation_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'salutation' AND constraint_name = 'FK_salutation_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE salutation ADD CONSTRAINT FK_salutation_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_salutation_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'salutation' AND constraint_name = 'FK_salutation_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE salutation ADD CONSTRAINT FK_salutation_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_salutation_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'signature' AND constraint_name = 'FK_signature_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE signature ADD CONSTRAINT FK_signature_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_signature_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'signature' AND constraint_name = 'FK_signature_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE signature ADD CONSTRAINT FK_signature_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_signature_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'signature' AND constraint_name = 'FK_signature_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE signature ADD CONSTRAINT FK_signature_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_signature_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'system_address' AND constraint_name = 'FK_system_address_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE system_address ADD CONSTRAINT FK_system_address_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_system_address_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'system_address' AND constraint_name = 'FK_system_address_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE system_address ADD CONSTRAINT FK_system_address_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_system_address_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'system_address' AND constraint_name = 'FK_system_address_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE system_address ADD CONSTRAINT FK_system_address_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_system_address_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'system_maintenance' AND constraint_name = 'FK_system_maintenance_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE system_maintenance ADD CONSTRAINT FK_system_maintenance_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_system_maintenance_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'system_maintenance' AND constraint_name = 'FK_system_maintenance_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE system_maintenance ADD CONSTRAINT FK_system_maintenance_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_system_maintenance_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'system_maintenance' AND constraint_name = 'FK_system_maintenance_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE system_maintenance ADD CONSTRAINT FK_system_maintenance_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_system_maintenance_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'follow_up_possible' AND constraint_name = 'FK_follow_up_possible_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE follow_up_possible ADD CONSTRAINT FK_follow_up_possible_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_follow_up_possible_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'follow_up_possible' AND constraint_name = 'FK_follow_up_possible_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE follow_up_possible ADD CONSTRAINT FK_follow_up_possible_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_follow_up_possible_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'follow_up_possible' AND constraint_name = 'FK_follow_up_possible_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE follow_up_possible ADD CONSTRAINT FK_follow_up_possible_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_follow_up_possible_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue' AND constraint_name = 'FK_queue_follow_up_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue ADD CONSTRAINT FK_queue_follow_up_id_id FOREIGN KEY (follow_up_id) REFERENCES follow_up_possible (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_follow_up_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue' AND constraint_name = 'FK_queue_group_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue ADD CONSTRAINT FK_queue_group_id_id FOREIGN KEY (group_id) REFERENCES groups (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_group_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue' AND constraint_name = 'FK_queue_salutation_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue ADD CONSTRAINT FK_queue_salutation_id_id FOREIGN KEY (salutation_id) REFERENCES salutation (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_salutation_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue' AND constraint_name = 'FK_queue_signature_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue ADD CONSTRAINT FK_queue_signature_id_id FOREIGN KEY (signature_id) REFERENCES signature (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_signature_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue' AND constraint_name = 'FK_queue_system_address_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue ADD CONSTRAINT FK_queue_system_address_id_id FOREIGN KEY (system_address_id) REFERENCES system_address (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_system_address_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue' AND constraint_name = 'FK_queue_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue ADD CONSTRAINT FK_queue_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue' AND constraint_name = 'FK_queue_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue ADD CONSTRAINT FK_queue_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue' AND constraint_name = 'FK_queue_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue ADD CONSTRAINT FK_queue_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue_preferences' AND constraint_name = 'FK_queue_preferences_queue_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue_preferences ADD CONSTRAINT FK_queue_preferences_queue_id_id FOREIGN KEY (queue_id) REFERENCES queue (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_preferences_queue_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_priority' AND constraint_name = 'FK_ticket_priority_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_priority ADD CONSTRAINT FK_ticket_priority_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_priority_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_priority' AND constraint_name = 'FK_ticket_priority_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_priority ADD CONSTRAINT FK_ticket_priority_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_priority_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_type' AND constraint_name = 'FK_ticket_type_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_type ADD CONSTRAINT FK_ticket_type_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_type_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_type' AND constraint_name = 'FK_ticket_type_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_type ADD CONSTRAINT FK_ticket_type_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_type_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_type' AND constraint_name = 'FK_ticket_type_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_type ADD CONSTRAINT FK_ticket_type_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_type_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_lock_type' AND constraint_name = 'FK_ticket_lock_type_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_lock_type ADD CONSTRAINT FK_ticket_lock_type_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_lock_type_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_lock_type' AND constraint_name = 'FK_ticket_lock_type_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_lock_type ADD CONSTRAINT FK_ticket_lock_type_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_lock_type_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_lock_type' AND constraint_name = 'FK_ticket_lock_type_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_lock_type ADD CONSTRAINT FK_ticket_lock_type_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_lock_type_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_state' AND constraint_name = 'FK_ticket_state_type_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_state ADD CONSTRAINT FK_ticket_state_type_id_id FOREIGN KEY (type_id) REFERENCES ticket_state_type (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_state_type_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_state' AND constraint_name = 'FK_ticket_state_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_state ADD CONSTRAINT FK_ticket_state_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_state_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_state' AND constraint_name = 'FK_ticket_state_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_state ADD CONSTRAINT FK_ticket_state_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_state_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_state' AND constraint_name = 'FK_ticket_state_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_state ADD CONSTRAINT FK_ticket_state_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_state_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_state_type' AND constraint_name = 'FK_ticket_state_type_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_state_type ADD CONSTRAINT FK_ticket_state_type_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_state_type_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_state_type' AND constraint_name = 'FK_ticket_state_type_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_state_type ADD CONSTRAINT FK_ticket_state_type_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_state_type_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket' AND constraint_name = 'FK_ticket_queue_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket ADD CONSTRAINT FK_ticket_queue_id_id FOREIGN KEY (queue_id) REFERENCES queue (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_queue_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket' AND constraint_name = 'FK_ticket_service_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket ADD CONSTRAINT FK_ticket_service_id_id FOREIGN KEY (service_id) REFERENCES service (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_service_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket' AND constraint_name = 'FK_ticket_sla_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket ADD CONSTRAINT FK_ticket_sla_id_id FOREIGN KEY (sla_id) REFERENCES sla (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_sla_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket' AND constraint_name = 'FK_ticket_ticket_lock_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket ADD CONSTRAINT FK_ticket_ticket_lock_id_id FOREIGN KEY (ticket_lock_id) REFERENCES ticket_lock_type (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_ticket_lock_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket' AND constraint_name = 'FK_ticket_ticket_priority_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket ADD CONSTRAINT FK_ticket_ticket_priority_id_id FOREIGN KEY (ticket_priority_id) REFERENCES ticket_priority (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_ticket_priority_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket' AND constraint_name = 'FK_ticket_ticket_state_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket ADD CONSTRAINT FK_ticket_ticket_state_id_id FOREIGN KEY (ticket_state_id) REFERENCES ticket_state (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_ticket_state_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket' AND constraint_name = 'FK_ticket_type_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket ADD CONSTRAINT FK_ticket_type_id_id FOREIGN KEY (type_id) REFERENCES ticket_type (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_type_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket' AND constraint_name = 'FK_ticket_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket ADD CONSTRAINT FK_ticket_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket' AND constraint_name = 'FK_ticket_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket ADD CONSTRAINT FK_ticket_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket' AND constraint_name = 'FK_ticket_user_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket ADD CONSTRAINT FK_ticket_user_id_id FOREIGN KEY (user_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_user_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket' AND constraint_name = 'FK_ticket_responsible_user_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket ADD CONSTRAINT FK_ticket_responsible_user_id_id FOREIGN KEY (responsible_user_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_responsible_user_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_flag' AND constraint_name = 'FK_ticket_flag_ticket_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_flag ADD CONSTRAINT FK_ticket_flag_ticket_id_id FOREIGN KEY (ticket_id) REFERENCES ticket (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_flag_ticket_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_flag' AND constraint_name = 'FK_ticket_flag_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_flag ADD CONSTRAINT FK_ticket_flag_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_flag_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_history' AND constraint_name = 'FK_ticket_history_article_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_history ADD CONSTRAINT FK_ticket_history_article_id_id FOREIGN KEY (article_id) REFERENCES article (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_history_article_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_history' AND constraint_name = 'FK_ticket_history_queue_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_history ADD CONSTRAINT FK_ticket_history_queue_id_id FOREIGN KEY (queue_id) REFERENCES queue (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_history_queue_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_history' AND constraint_name = 'FK_ticket_history_ticket_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_history ADD CONSTRAINT FK_ticket_history_ticket_id_id FOREIGN KEY (ticket_id) REFERENCES ticket (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_history_ticket_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_history' AND constraint_name = 'FK_ticket_history_history_type_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_history ADD CONSTRAINT FK_ticket_history_history_type_id_id FOREIGN KEY (history_type_id) REFERENCES ticket_history_type (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_history_history_type_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_history' AND constraint_name = 'FK_ticket_history_priority_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_history ADD CONSTRAINT FK_ticket_history_priority_id_id FOREIGN KEY (priority_id) REFERENCES ticket_priority (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_history_priority_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_history' AND constraint_name = 'FK_ticket_history_state_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_history ADD CONSTRAINT FK_ticket_history_state_id_id FOREIGN KEY (state_id) REFERENCES ticket_state (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_history_state_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_history' AND constraint_name = 'FK_ticket_history_type_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_history ADD CONSTRAINT FK_ticket_history_type_id_id FOREIGN KEY (type_id) REFERENCES ticket_type (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_history_type_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_history' AND constraint_name = 'FK_ticket_history_owner_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_history ADD CONSTRAINT FK_ticket_history_owner_id_id FOREIGN KEY (owner_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_history_owner_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_history' AND constraint_name = 'FK_ticket_history_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_history ADD CONSTRAINT FK_ticket_history_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_history_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_history' AND constraint_name = 'FK_ticket_history_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_history ADD CONSTRAINT FK_ticket_history_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_history_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_history_type' AND constraint_name = 'FK_ticket_history_type_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_history_type ADD CONSTRAINT FK_ticket_history_type_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_history_type_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_history_type' AND constraint_name = 'FK_ticket_history_type_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_history_type ADD CONSTRAINT FK_ticket_history_type_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_history_type_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_history_type' AND constraint_name = 'FK_ticket_history_type_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_history_type ADD CONSTRAINT FK_ticket_history_type_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_history_type_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_watcher' AND constraint_name = 'FK_ticket_watcher_ticket_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_watcher ADD CONSTRAINT FK_ticket_watcher_ticket_id_id FOREIGN KEY (ticket_id) REFERENCES ticket (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_watcher_ticket_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_watcher' AND constraint_name = 'FK_ticket_watcher_user_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_watcher ADD CONSTRAINT FK_ticket_watcher_user_id_id FOREIGN KEY (user_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_watcher_user_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_watcher' AND constraint_name = 'FK_ticket_watcher_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_watcher ADD CONSTRAINT FK_ticket_watcher_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_watcher_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_watcher' AND constraint_name = 'FK_ticket_watcher_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_watcher ADD CONSTRAINT FK_ticket_watcher_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_watcher_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_index' AND constraint_name = 'FK_ticket_index_group_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_index ADD CONSTRAINT FK_ticket_index_group_id_id FOREIGN KEY (group_id) REFERENCES groups (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_index_group_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_index' AND constraint_name = 'FK_ticket_index_queue_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_index ADD CONSTRAINT FK_ticket_index_queue_id_id FOREIGN KEY (queue_id) REFERENCES queue (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_index_queue_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_index' AND constraint_name = 'FK_ticket_index_ticket_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_index ADD CONSTRAINT FK_ticket_index_ticket_id_id FOREIGN KEY (ticket_id) REFERENCES ticket (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_index_ticket_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'ticket_lock_index' AND constraint_name = 'FK_ticket_lock_index_ticket_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE ticket_lock_index ADD CONSTRAINT FK_ticket_lock_index_ticket_id_id FOREIGN KEY (ticket_id) REFERENCES ticket (id)', 'SELECT ''INFO: Foreign key constraint FK_ticket_lock_index_ticket_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_sender_type' AND constraint_name = 'FK_article_sender_type_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_sender_type ADD CONSTRAINT FK_article_sender_type_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_article_sender_type_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_sender_type' AND constraint_name = 'FK_article_sender_type_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_sender_type ADD CONSTRAINT FK_article_sender_type_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_article_sender_type_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_sender_type' AND constraint_name = 'FK_article_sender_type_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_sender_type ADD CONSTRAINT FK_article_sender_type_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_article_sender_type_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_flag' AND constraint_name = 'FK_article_flag_article_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_flag ADD CONSTRAINT FK_article_flag_article_id_id FOREIGN KEY (article_id) REFERENCES article (id)', 'SELECT ''INFO: Foreign key constraint FK_article_flag_article_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_flag' AND constraint_name = 'FK_article_flag_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_flag ADD CONSTRAINT FK_article_flag_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_article_flag_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'communication_channel' AND constraint_name = 'FK_communication_channel_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE communication_channel ADD CONSTRAINT FK_communication_channel_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_communication_channel_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'communication_channel' AND constraint_name = 'FK_communication_channel_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE communication_channel ADD CONSTRAINT FK_communication_channel_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_communication_channel_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'communication_channel' AND constraint_name = 'FK_communication_channel_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE communication_channel ADD CONSTRAINT FK_communication_channel_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_communication_channel_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article' AND constraint_name = 'FK_article_article_sender_type_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article ADD CONSTRAINT FK_article_article_sender_type_id_id FOREIGN KEY (article_sender_type_id) REFERENCES article_sender_type (id)', 'SELECT ''INFO: Foreign key constraint FK_article_article_sender_type_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article' AND constraint_name = 'FK_article_communication_channel_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article ADD CONSTRAINT FK_article_communication_channel_id_id FOREIGN KEY (communication_channel_id) REFERENCES communication_channel (id)', 'SELECT ''INFO: Foreign key constraint FK_article_communication_channel_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article' AND constraint_name = 'FK_article_ticket_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article ADD CONSTRAINT FK_article_ticket_id_id FOREIGN KEY (ticket_id) REFERENCES ticket (id)', 'SELECT ''INFO: Foreign key constraint FK_article_ticket_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article' AND constraint_name = 'FK_article_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article ADD CONSTRAINT FK_article_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_article_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article' AND constraint_name = 'FK_article_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article ADD CONSTRAINT FK_article_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_article_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_data_mime' AND constraint_name = 'FK_article_data_mime_article_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_data_mime ADD CONSTRAINT FK_article_data_mime_article_id_id FOREIGN KEY (article_id) REFERENCES article (id)', 'SELECT ''INFO: Foreign key constraint FK_article_data_mime_article_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_data_mime' AND constraint_name = 'FK_article_data_mime_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_data_mime ADD CONSTRAINT FK_article_data_mime_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_article_data_mime_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_data_mime' AND constraint_name = 'FK_article_data_mime_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_data_mime ADD CONSTRAINT FK_article_data_mime_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_article_data_mime_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_search_index' AND constraint_name = 'FK_article_search_index_article_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_search_index ADD CONSTRAINT FK_article_search_index_article_id_id FOREIGN KEY (article_id) REFERENCES article (id)', 'SELECT ''INFO: Foreign key constraint FK_article_search_index_article_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_search_index' AND constraint_name = 'FK_article_search_index_ticket_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_search_index ADD CONSTRAINT FK_article_search_index_ticket_id_id FOREIGN KEY (ticket_id) REFERENCES ticket (id)', 'SELECT ''INFO: Foreign key constraint FK_article_search_index_ticket_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_data_mime_plain' AND constraint_name = 'FK_article_data_mime_plain_article_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_data_mime_plain ADD CONSTRAINT FK_article_data_mime_plain_article_id_id FOREIGN KEY (article_id) REFERENCES article (id)', 'SELECT ''INFO: Foreign key constraint FK_article_data_mime_plain_article_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_data_mime_plain' AND constraint_name = 'FK_article_data_mime_plain_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_data_mime_plain ADD CONSTRAINT FK_article_data_mime_plain_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_article_data_mime_plain_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_data_mime_plain' AND constraint_name = 'FK_article_data_mime_plain_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_data_mime_plain ADD CONSTRAINT FK_article_data_mime_plain_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_article_data_mime_plain_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_data_mime_attachment' AND constraint_name = 'FK_article_data_mime_attachment_article_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_data_mime_attachment ADD CONSTRAINT FK_article_data_mime_attachment_article_id_id FOREIGN KEY (article_id) REFERENCES article (id)', 'SELECT ''INFO: Foreign key constraint FK_article_data_mime_attachment_article_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_data_mime_attachment' AND constraint_name = 'FK_article_data_mime_attachment_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_data_mime_attachment ADD CONSTRAINT FK_article_data_mime_attachment_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_article_data_mime_attachment_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_data_mime_attachment' AND constraint_name = 'FK_article_data_mime_attachment_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_data_mime_attachment ADD CONSTRAINT FK_article_data_mime_attachment_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_article_data_mime_attachment_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_data_mime_send_error' AND constraint_name = 'FK_article_data_mime_send_error_article_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_data_mime_send_error ADD CONSTRAINT FK_article_data_mime_send_error_article_id_id FOREIGN KEY (article_id) REFERENCES article (id)', 'SELECT ''INFO: Foreign key constraint FK_article_data_mime_send_error_article_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'article_data_otrs_chat' AND constraint_name = 'FK_article_data_otrs_chat_article_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE article_data_otrs_chat ADD CONSTRAINT FK_article_data_otrs_chat_article_id_id FOREIGN KEY (article_id) REFERENCES article (id)', 'SELECT ''INFO: Foreign key constraint FK_article_data_otrs_chat_article_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'time_accounting' AND constraint_name = 'FK_time_accounting_article_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE time_accounting ADD CONSTRAINT FK_time_accounting_article_id_id FOREIGN KEY (article_id) REFERENCES article (id)', 'SELECT ''INFO: Foreign key constraint FK_time_accounting_article_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'time_accounting' AND constraint_name = 'FK_time_accounting_ticket_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE time_accounting ADD CONSTRAINT FK_time_accounting_ticket_id_id FOREIGN KEY (ticket_id) REFERENCES ticket (id)', 'SELECT ''INFO: Foreign key constraint FK_time_accounting_ticket_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'time_accounting' AND constraint_name = 'FK_time_accounting_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE time_accounting ADD CONSTRAINT FK_time_accounting_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_time_accounting_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'time_accounting' AND constraint_name = 'FK_time_accounting_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE time_accounting ADD CONSTRAINT FK_time_accounting_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_time_accounting_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'standard_template' AND constraint_name = 'FK_standard_template_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE standard_template ADD CONSTRAINT FK_standard_template_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_standard_template_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'standard_template' AND constraint_name = 'FK_standard_template_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE standard_template ADD CONSTRAINT FK_standard_template_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_standard_template_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'standard_template' AND constraint_name = 'FK_standard_template_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE standard_template ADD CONSTRAINT FK_standard_template_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_standard_template_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue_standard_template' AND constraint_name = 'FK_queue_standard_template_queue_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue_standard_template ADD CONSTRAINT FK_queue_standard_template_queue_id_id FOREIGN KEY (queue_id) REFERENCES queue (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_standard_template_queue_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue_standard_template' AND constraint_name = 'FK_queue_standard_template_standard_template_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue_standard_template ADD CONSTRAINT FK_queue_standard_template_standard_template_id_id FOREIGN KEY (standard_template_id) REFERENCES standard_template (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_standard_template_standard_template_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue_standard_template' AND constraint_name = 'FK_queue_standard_template_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue_standard_template ADD CONSTRAINT FK_queue_standard_template_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_standard_template_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue_standard_template' AND constraint_name = 'FK_queue_standard_template_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue_standard_template ADD CONSTRAINT FK_queue_standard_template_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_standard_template_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'standard_attachment' AND constraint_name = 'FK_standard_attachment_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE standard_attachment ADD CONSTRAINT FK_standard_attachment_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_standard_attachment_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'standard_attachment' AND constraint_name = 'FK_standard_attachment_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE standard_attachment ADD CONSTRAINT FK_standard_attachment_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_standard_attachment_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'standard_attachment' AND constraint_name = 'FK_standard_attachment_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE standard_attachment ADD CONSTRAINT FK_standard_attachment_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_standard_attachment_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'standard_template_attachment' AND constraint_name = 'FK_standard_template_attachment_standard_attachment_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE standard_template_attachment ADD CONSTRAINT FK_standard_template_attachment_standard_attachment_id_id FOREIGN KEY (standard_attachment_id) REFERENCES standard_attachment (id)', 'SELECT ''INFO: Foreign key constraint FK_standard_template_attachment_standard_attachment_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'standard_template_attachment' AND constraint_name = 'FK_standard_template_attachment_standard_template_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE standard_template_attachment ADD CONSTRAINT FK_standard_template_attachment_standard_template_id_id FOREIGN KEY (standard_template_id) REFERENCES standard_template (id)', 'SELECT ''INFO: Foreign key constraint FK_standard_template_attachment_standard_template_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'standard_template_attachment' AND constraint_name = 'FK_standard_template_attachment_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE standard_template_attachment ADD CONSTRAINT FK_standard_template_attachment_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_standard_template_attachment_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'standard_template_attachment' AND constraint_name = 'FK_standard_template_attachment_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE standard_template_attachment ADD CONSTRAINT FK_standard_template_attachment_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_standard_template_attachment_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'auto_response_type' AND constraint_name = 'FK_auto_response_type_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE auto_response_type ADD CONSTRAINT FK_auto_response_type_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_auto_response_type_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'auto_response_type' AND constraint_name = 'FK_auto_response_type_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE auto_response_type ADD CONSTRAINT FK_auto_response_type_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_auto_response_type_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'auto_response_type' AND constraint_name = 'FK_auto_response_type_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE auto_response_type ADD CONSTRAINT FK_auto_response_type_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_auto_response_type_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'auto_response' AND constraint_name = 'FK_auto_response_type_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE auto_response ADD CONSTRAINT FK_auto_response_type_id_id FOREIGN KEY (type_id) REFERENCES auto_response_type (id)', 'SELECT ''INFO: Foreign key constraint FK_auto_response_type_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'auto_response' AND constraint_name = 'FK_auto_response_system_address_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE auto_response ADD CONSTRAINT FK_auto_response_system_address_id_id FOREIGN KEY (system_address_id) REFERENCES system_address (id)', 'SELECT ''INFO: Foreign key constraint FK_auto_response_system_address_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'auto_response' AND constraint_name = 'FK_auto_response_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE auto_response ADD CONSTRAINT FK_auto_response_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_auto_response_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'auto_response' AND constraint_name = 'FK_auto_response_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE auto_response ADD CONSTRAINT FK_auto_response_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_auto_response_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'auto_response' AND constraint_name = 'FK_auto_response_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE auto_response ADD CONSTRAINT FK_auto_response_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_auto_response_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue_auto_response' AND constraint_name = 'FK_queue_auto_response_auto_response_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue_auto_response ADD CONSTRAINT FK_queue_auto_response_auto_response_id_id FOREIGN KEY (auto_response_id) REFERENCES auto_response (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_auto_response_auto_response_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue_auto_response' AND constraint_name = 'FK_queue_auto_response_queue_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue_auto_response ADD CONSTRAINT FK_queue_auto_response_queue_id_id FOREIGN KEY (queue_id) REFERENCES queue (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_auto_response_queue_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue_auto_response' AND constraint_name = 'FK_queue_auto_response_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue_auto_response ADD CONSTRAINT FK_queue_auto_response_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_auto_response_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'queue_auto_response' AND constraint_name = 'FK_queue_auto_response_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE queue_auto_response ADD CONSTRAINT FK_queue_auto_response_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_queue_auto_response_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'service' AND constraint_name = 'FK_service_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE service ADD CONSTRAINT FK_service_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_service_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'service' AND constraint_name = 'FK_service_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE service ADD CONSTRAINT FK_service_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_service_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'service_preferences' AND constraint_name = 'FK_service_preferences_service_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE service_preferences ADD CONSTRAINT FK_service_preferences_service_id_id FOREIGN KEY (service_id) REFERENCES service (id)', 'SELECT ''INFO: Foreign key constraint FK_service_preferences_service_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'service_customer_user' AND constraint_name = 'FK_service_customer_user_service_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE service_customer_user ADD CONSTRAINT FK_service_customer_user_service_id_id FOREIGN KEY (service_id) REFERENCES service (id)', 'SELECT ''INFO: Foreign key constraint FK_service_customer_user_service_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'service_customer_user' AND constraint_name = 'FK_service_customer_user_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE service_customer_user ADD CONSTRAINT FK_service_customer_user_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_service_customer_user_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sla' AND constraint_name = 'FK_sla_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sla ADD CONSTRAINT FK_sla_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sla_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sla' AND constraint_name = 'FK_sla_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sla ADD CONSTRAINT FK_sla_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sla_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sla_preferences' AND constraint_name = 'FK_sla_preferences_sla_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sla_preferences ADD CONSTRAINT FK_sla_preferences_sla_id_id FOREIGN KEY (sla_id) REFERENCES sla (id)', 'SELECT ''INFO: Foreign key constraint FK_sla_preferences_sla_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'service_sla' AND constraint_name = 'FK_service_sla_service_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE service_sla ADD CONSTRAINT FK_service_sla_service_id_id FOREIGN KEY (service_id) REFERENCES service (id)', 'SELECT ''INFO: Foreign key constraint FK_service_sla_service_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'service_sla' AND constraint_name = 'FK_service_sla_sla_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE service_sla ADD CONSTRAINT FK_service_sla_sla_id_id FOREIGN KEY (sla_id) REFERENCES sla (id)', 'SELECT ''INFO: Foreign key constraint FK_service_sla_sla_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'customer_user' AND constraint_name = 'FK_customer_user_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE customer_user ADD CONSTRAINT FK_customer_user_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_customer_user_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'customer_user' AND constraint_name = 'FK_customer_user_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE customer_user ADD CONSTRAINT FK_customer_user_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_customer_user_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'customer_user' AND constraint_name = 'FK_customer_user_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE customer_user ADD CONSTRAINT FK_customer_user_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_customer_user_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'customer_user_customer' AND constraint_name = 'FK_customer_user_customer_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE customer_user_customer ADD CONSTRAINT FK_customer_user_customer_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_customer_user_customer_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'customer_user_customer' AND constraint_name = 'FK_customer_user_customer_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE customer_user_customer ADD CONSTRAINT FK_customer_user_customer_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_customer_user_customer_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'mail_account' AND constraint_name = 'FK_mail_account_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE mail_account ADD CONSTRAINT FK_mail_account_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_mail_account_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'mail_account' AND constraint_name = 'FK_mail_account_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE mail_account ADD CONSTRAINT FK_mail_account_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_mail_account_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'mail_account' AND constraint_name = 'FK_mail_account_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE mail_account ADD CONSTRAINT FK_mail_account_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_mail_account_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'notification_event' AND constraint_name = 'FK_notification_event_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE notification_event ADD CONSTRAINT FK_notification_event_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_notification_event_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'notification_event' AND constraint_name = 'FK_notification_event_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE notification_event ADD CONSTRAINT FK_notification_event_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_notification_event_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'notification_event' AND constraint_name = 'FK_notification_event_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE notification_event ADD CONSTRAINT FK_notification_event_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_notification_event_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'notification_event_message' AND constraint_name = 'FK_notification_event_message_notification_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE notification_event_message ADD CONSTRAINT FK_notification_event_message_notification_id_id FOREIGN KEY (notification_id) REFERENCES notification_event (id)', 'SELECT ''INFO: Foreign key constraint FK_notification_event_message_notification_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'notification_event_item' AND constraint_name = 'FK_notification_event_item_notification_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE notification_event_item ADD CONSTRAINT FK_notification_event_item_notification_id_id FOREIGN KEY (notification_id) REFERENCES notification_event (id)', 'SELECT ''INFO: Foreign key constraint FK_notification_event_item_notification_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'link_type' AND constraint_name = 'FK_link_type_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE link_type ADD CONSTRAINT FK_link_type_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_link_type_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'link_type' AND constraint_name = 'FK_link_type_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE link_type ADD CONSTRAINT FK_link_type_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_link_type_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'link_type' AND constraint_name = 'FK_link_type_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE link_type ADD CONSTRAINT FK_link_type_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_link_type_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'link_state' AND constraint_name = 'FK_link_state_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE link_state ADD CONSTRAINT FK_link_state_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_link_state_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'link_state' AND constraint_name = 'FK_link_state_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE link_state ADD CONSTRAINT FK_link_state_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_link_state_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'link_state' AND constraint_name = 'FK_link_state_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE link_state ADD CONSTRAINT FK_link_state_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_link_state_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'link_relation' AND constraint_name = 'FK_link_relation_source_object_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE link_relation ADD CONSTRAINT FK_link_relation_source_object_id_id FOREIGN KEY (source_object_id) REFERENCES link_object (id)', 'SELECT ''INFO: Foreign key constraint FK_link_relation_source_object_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'link_relation' AND constraint_name = 'FK_link_relation_target_object_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE link_relation ADD CONSTRAINT FK_link_relation_target_object_id_id FOREIGN KEY (target_object_id) REFERENCES link_object (id)', 'SELECT ''INFO: Foreign key constraint FK_link_relation_target_object_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'link_relation' AND constraint_name = 'FK_link_relation_state_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE link_relation ADD CONSTRAINT FK_link_relation_state_id_id FOREIGN KEY (state_id) REFERENCES link_state (id)', 'SELECT ''INFO: Foreign key constraint FK_link_relation_state_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'link_relation' AND constraint_name = 'FK_link_relation_type_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE link_relation ADD CONSTRAINT FK_link_relation_type_id_id FOREIGN KEY (type_id) REFERENCES link_type (id)', 'SELECT ''INFO: Foreign key constraint FK_link_relation_type_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'link_relation' AND constraint_name = 'FK_link_relation_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE link_relation ADD CONSTRAINT FK_link_relation_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_link_relation_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'system_data' AND constraint_name = 'FK_system_data_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE system_data ADD CONSTRAINT FK_system_data_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_system_data_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'system_data' AND constraint_name = 'FK_system_data_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE system_data ADD CONSTRAINT FK_system_data_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_system_data_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'virtual_fs_preferences' AND constraint_name = 'FK_virtual_fs_preferences_virtual_fs_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE virtual_fs_preferences ADD CONSTRAINT FK_virtual_fs_preferences_virtual_fs_id_id FOREIGN KEY (virtual_fs_id) REFERENCES virtual_fs (id)', 'SELECT ''INFO: Foreign key constraint FK_virtual_fs_preferences_virtual_fs_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'package_repository' AND constraint_name = 'FK_package_repository_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE package_repository ADD CONSTRAINT FK_package_repository_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_package_repository_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'package_repository' AND constraint_name = 'FK_package_repository_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE package_repository ADD CONSTRAINT FK_package_repository_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_package_repository_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'gi_webservice_config' AND constraint_name = 'FK_gi_webservice_config_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE gi_webservice_config ADD CONSTRAINT FK_gi_webservice_config_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_gi_webservice_config_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'gi_webservice_config' AND constraint_name = 'FK_gi_webservice_config_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE gi_webservice_config ADD CONSTRAINT FK_gi_webservice_config_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_gi_webservice_config_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'gi_webservice_config' AND constraint_name = 'FK_gi_webservice_config_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE gi_webservice_config ADD CONSTRAINT FK_gi_webservice_config_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_gi_webservice_config_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'gi_webservice_config_history' AND constraint_name = 'FK_gi_webservice_config_history_config_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE gi_webservice_config_history ADD CONSTRAINT FK_gi_webservice_config_history_config_id_id FOREIGN KEY (config_id) REFERENCES gi_webservice_config (id)', 'SELECT ''INFO: Foreign key constraint FK_gi_webservice_config_history_config_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'gi_webservice_config_history' AND constraint_name = 'FK_gi_webservice_config_history_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE gi_webservice_config_history ADD CONSTRAINT FK_gi_webservice_config_history_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_gi_webservice_config_history_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'gi_webservice_config_history' AND constraint_name = 'FK_gi_webservice_config_history_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE gi_webservice_config_history ADD CONSTRAINT FK_gi_webservice_config_history_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_gi_webservice_config_history_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'gi_debugger_entry' AND constraint_name = 'FK_gi_debugger_entry_webservice_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE gi_debugger_entry ADD CONSTRAINT FK_gi_debugger_entry_webservice_id_id FOREIGN KEY (webservice_id) REFERENCES gi_webservice_config (id)', 'SELECT ''INFO: Foreign key constraint FK_gi_debugger_entry_webservice_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'gi_debugger_entry_content' AND constraint_name = 'FK_gi_debugger_entry_content_gi_debugger_entry_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE gi_debugger_entry_content ADD CONSTRAINT FK_gi_debugger_entry_content_gi_debugger_entry_id_id FOREIGN KEY (gi_debugger_entry_id) REFERENCES gi_debugger_entry (id)', 'SELECT ''INFO: Foreign key constraint FK_gi_debugger_entry_content_gi_debugger_entry_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'smime_signer_cert_relations' AND constraint_name = 'FK_smime_signer_cert_relations_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE smime_signer_cert_relations ADD CONSTRAINT FK_smime_signer_cert_relations_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_smime_signer_cert_relations_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'smime_signer_cert_relations' AND constraint_name = 'FK_smime_signer_cert_relations_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE smime_signer_cert_relations ADD CONSTRAINT FK_smime_signer_cert_relations_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_smime_signer_cert_relations_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'dynamic_field_value' AND constraint_name = 'FK_dynamic_field_value_field_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE dynamic_field_value ADD CONSTRAINT FK_dynamic_field_value_field_id_id FOREIGN KEY (field_id) REFERENCES dynamic_field (id)', 'SELECT ''INFO: Foreign key constraint FK_dynamic_field_value_field_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'dynamic_field' AND constraint_name = 'FK_dynamic_field_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE dynamic_field ADD CONSTRAINT FK_dynamic_field_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_dynamic_field_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'dynamic_field' AND constraint_name = 'FK_dynamic_field_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE dynamic_field ADD CONSTRAINT FK_dynamic_field_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_dynamic_field_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'dynamic_field' AND constraint_name = 'FK_dynamic_field_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE dynamic_field ADD CONSTRAINT FK_dynamic_field_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_dynamic_field_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'pm_process' AND constraint_name = 'FK_pm_process_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE pm_process ADD CONSTRAINT FK_pm_process_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_pm_process_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'pm_process' AND constraint_name = 'FK_pm_process_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE pm_process ADD CONSTRAINT FK_pm_process_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_pm_process_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'pm_activity' AND constraint_name = 'FK_pm_activity_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE pm_activity ADD CONSTRAINT FK_pm_activity_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_pm_activity_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'pm_activity' AND constraint_name = 'FK_pm_activity_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE pm_activity ADD CONSTRAINT FK_pm_activity_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_pm_activity_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'pm_activity_dialog' AND constraint_name = 'FK_pm_activity_dialog_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE pm_activity_dialog ADD CONSTRAINT FK_pm_activity_dialog_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_pm_activity_dialog_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'pm_activity_dialog' AND constraint_name = 'FK_pm_activity_dialog_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE pm_activity_dialog ADD CONSTRAINT FK_pm_activity_dialog_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_pm_activity_dialog_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'pm_transition' AND constraint_name = 'FK_pm_transition_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE pm_transition ADD CONSTRAINT FK_pm_transition_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_pm_transition_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'pm_transition' AND constraint_name = 'FK_pm_transition_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE pm_transition ADD CONSTRAINT FK_pm_transition_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_pm_transition_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'pm_transition_action' AND constraint_name = 'FK_pm_transition_action_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE pm_transition_action ADD CONSTRAINT FK_pm_transition_action_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_pm_transition_action_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'pm_transition_action' AND constraint_name = 'FK_pm_transition_action_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE pm_transition_action ADD CONSTRAINT FK_pm_transition_action_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_pm_transition_action_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'cloud_service_config' AND constraint_name = 'FK_cloud_service_config_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE cloud_service_config ADD CONSTRAINT FK_cloud_service_config_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_cloud_service_config_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'cloud_service_config' AND constraint_name = 'FK_cloud_service_config_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE cloud_service_config ADD CONSTRAINT FK_cloud_service_config_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_cloud_service_config_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'cloud_service_config' AND constraint_name = 'FK_cloud_service_config_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE cloud_service_config ADD CONSTRAINT FK_cloud_service_config_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_cloud_service_config_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_default' AND constraint_name = 'FK_sysconfig_default_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_default ADD CONSTRAINT FK_sysconfig_default_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_default_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_default' AND constraint_name = 'FK_sysconfig_default_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_default ADD CONSTRAINT FK_sysconfig_default_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_default_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_default' AND constraint_name = 'FK_sysconfig_default_exclusive_lock_user_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_default ADD CONSTRAINT FK_sysconfig_default_exclusive_lock_user_id_id FOREIGN KEY (exclusive_lock_user_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_default_exclusive_lock_user_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_default_version' AND constraint_name = 'FK_sysconfig_default_version_sysconfig_default_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_default_version ADD CONSTRAINT FK_sysconfig_default_version_sysconfig_default_id_id FOREIGN KEY (sysconfig_default_id) REFERENCES sysconfig_default (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_default_version_sysconfig_default_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_default_version' AND constraint_name = 'FK_sysconfig_default_version_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_default_version ADD CONSTRAINT FK_sysconfig_default_version_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_default_version_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_default_version' AND constraint_name = 'FK_sysconfig_default_version_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_default_version ADD CONSTRAINT FK_sysconfig_default_version_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_default_version_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_modified' AND constraint_name = 'FK_sysconfig_modified_sysconfig_default_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_modified ADD CONSTRAINT FK_sysconfig_modified_sysconfig_default_id_id FOREIGN KEY (sysconfig_default_id) REFERENCES sysconfig_default (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_modified_sysconfig_default_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_modified' AND constraint_name = 'FK_sysconfig_modified_user_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_modified ADD CONSTRAINT FK_sysconfig_modified_user_id_id FOREIGN KEY (user_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_modified_user_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_modified' AND constraint_name = 'FK_sysconfig_modified_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_modified ADD CONSTRAINT FK_sysconfig_modified_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_modified_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_modified' AND constraint_name = 'FK_sysconfig_modified_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_modified ADD CONSTRAINT FK_sysconfig_modified_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_modified_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_modified_version' AND constraint_name = 'FK_sysconfig_modified_version_sysconfig_default_version_idaf');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_modified_version ADD CONSTRAINT FK_sysconfig_modified_version_sysconfig_default_version_idaf FOREIGN KEY (sysconfig_default_version_id) REFERENCES sysconfig_default_version (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_modified_version_sysconfig_default_version_idaf does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_modified_version' AND constraint_name = 'FK_sysconfig_modified_version_user_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_modified_version ADD CONSTRAINT FK_sysconfig_modified_version_user_id_id FOREIGN KEY (user_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_modified_version_user_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_modified_version' AND constraint_name = 'FK_sysconfig_modified_version_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_modified_version ADD CONSTRAINT FK_sysconfig_modified_version_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_modified_version_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_modified_version' AND constraint_name = 'FK_sysconfig_modified_version_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_modified_version ADD CONSTRAINT FK_sysconfig_modified_version_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_modified_version_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_deployment_lock' AND constraint_name = 'FK_sysconfig_deployment_lock_exclusive_lock_user_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_deployment_lock ADD CONSTRAINT FK_sysconfig_deployment_lock_exclusive_lock_user_id_id FOREIGN KEY (exclusive_lock_user_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_deployment_lock_exclusive_lock_user_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_deployment' AND constraint_name = 'FK_sysconfig_deployment_user_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_deployment ADD CONSTRAINT FK_sysconfig_deployment_user_id_id FOREIGN KEY (user_id) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_deployment_user_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'sysconfig_deployment' AND constraint_name = 'FK_sysconfig_deployment_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE sysconfig_deployment ADD CONSTRAINT FK_sysconfig_deployment_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_sysconfig_deployment_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'calendar' AND constraint_name = 'FK_calendar_group_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE calendar ADD CONSTRAINT FK_calendar_group_id_id FOREIGN KEY (group_id) REFERENCES groups (id)', 'SELECT ''INFO: Foreign key constraint FK_calendar_group_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'calendar' AND constraint_name = 'FK_calendar_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE calendar ADD CONSTRAINT FK_calendar_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_calendar_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'calendar' AND constraint_name = 'FK_calendar_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE calendar ADD CONSTRAINT FK_calendar_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_calendar_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'calendar' AND constraint_name = 'FK_calendar_valid_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE calendar ADD CONSTRAINT FK_calendar_valid_id_id FOREIGN KEY (valid_id) REFERENCES valid (id)', 'SELECT ''INFO: Foreign key constraint FK_calendar_valid_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'calendar_appointment' AND constraint_name = 'FK_calendar_appointment_calendar_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE calendar_appointment ADD CONSTRAINT FK_calendar_appointment_calendar_id_id FOREIGN KEY (calendar_id) REFERENCES calendar (id)', 'SELECT ''INFO: Foreign key constraint FK_calendar_appointment_calendar_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'calendar_appointment' AND constraint_name = 'FK_calendar_appointment_parent_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE calendar_appointment ADD CONSTRAINT FK_calendar_appointment_parent_id_id FOREIGN KEY (parent_id) REFERENCES calendar_appointment (id)', 'SELECT ''INFO: Foreign key constraint FK_calendar_appointment_parent_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'calendar_appointment' AND constraint_name = 'FK_calendar_appointment_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE calendar_appointment ADD CONSTRAINT FK_calendar_appointment_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_calendar_appointment_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'calendar_appointment' AND constraint_name = 'FK_calendar_appointment_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE calendar_appointment ADD CONSTRAINT FK_calendar_appointment_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_calendar_appointment_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'calendar_appointment_ticket' AND constraint_name = 'FK_calendar_appointment_ticket_calendar_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE calendar_appointment_ticket ADD CONSTRAINT FK_calendar_appointment_ticket_calendar_id_id FOREIGN KEY (calendar_id) REFERENCES calendar (id)', 'SELECT ''INFO: Foreign key constraint FK_calendar_appointment_ticket_calendar_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'calendar_appointment_ticket' AND constraint_name = 'FK_calendar_appointment_ticket_appointment_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE calendar_appointment_ticket ADD CONSTRAINT FK_calendar_appointment_ticket_appointment_id_id FOREIGN KEY (appointment_id) REFERENCES calendar_appointment (id)', 'SELECT ''INFO: Foreign key constraint FK_calendar_appointment_ticket_appointment_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'calendar_appointment_ticket' AND constraint_name = 'FK_calendar_appointment_ticket_ticket_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE calendar_appointment_ticket ADD CONSTRAINT FK_calendar_appointment_ticket_ticket_id_id FOREIGN KEY (ticket_id) REFERENCES ticket (id)', 'SELECT ''INFO: Foreign key constraint FK_calendar_appointment_ticket_ticket_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'mail_queue' AND constraint_name = 'FK_mail_queue_article_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE mail_queue ADD CONSTRAINT FK_mail_queue_article_id_id FOREIGN KEY (article_id) REFERENCES article (id)', 'SELECT ''INFO: Foreign key constraint FK_mail_queue_article_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'communication_log_object' AND constraint_name = 'FK_communication_log_object_communication_id_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE communication_log_object ADD CONSTRAINT FK_communication_log_object_communication_id_id FOREIGN KEY (communication_id) REFERENCES communication_log (id)', 'SELECT ''INFO: Foreign key constraint FK_communication_log_object_communication_id_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'communication_log_object_entry' AND constraint_name = 'FK_communication_log_object_entry_communication_log_objectaa');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE communication_log_object_entry ADD CONSTRAINT FK_communication_log_object_entry_communication_log_objectaa FOREIGN KEY (communication_log_object_id) REFERENCES communication_log_object (id)', 'SELECT ''INFO: Foreign key constraint FK_communication_log_object_entry_communication_log_objectaa does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'communication_log_obj_lookup' AND constraint_name = 'FK_communication_log_obj_lookup_communication_log_object_i0f');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE communication_log_obj_lookup ADD CONSTRAINT FK_communication_log_obj_lookup_communication_log_object_i0f FOREIGN KEY (communication_log_object_id) REFERENCES communication_log_object (id)', 'SELECT ''INFO: Foreign key constraint FK_communication_log_obj_lookup_communication_log_object_i0f does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'form_draft' AND constraint_name = 'FK_form_draft_create_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE form_draft ADD CONSTRAINT FK_form_draft_create_by_id FOREIGN KEY (create_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_form_draft_create_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;
SET @FKExists := (SELECT COUNT(*) FROM information_schema.table_constraints WHERE table_schema = DATABASE() AND table_name = 'form_draft' AND constraint_name = 'FK_form_draft_change_by_id');
SET @FKSQLStatement := IF( @FKExists = 0, 'ALTER TABLE form_draft ADD CONSTRAINT FK_form_draft_change_by_id FOREIGN KEY (change_by) REFERENCES users (id)', 'SELECT ''INFO: Foreign key constraint FK_form_draft_change_by_id does already exist, skipping.''' );
PREPARE FKStatement FROM @FKSQLStatement;
EXECUTE FKStatement;