2 ALTER TABLE Links ADD INDEX(LocalBase);
3 ALTER TABLE Links ADD FOREIGN KEY (LocalBase) REFERENCES Tickets(id);
4 ALTER TABLE Links ADD INDEX(LocalTarget);
5 ALTER TABLE Links ADD FOREIGN KEY (LocalTarget) REFERENCES Tickets(id);
6 ALTER TABLE Tickets ADD INDEX(Queue);
7 ALTER TABLE Tickets ADD FOREIGN KEY (Queue) REFERENCES Queues(id);
8 ALTER TABLE Tickets ADD INDEX(EffectiveId);
9 ALTER TABLE Tickets ADD FOREIGN KEY (EffectiveId) REFERENCES Tickets(id);
10 ALTER TABLE Tickets ADD INDEX(Owner);
11 ALTER TABLE Tickets ADD FOREIGN KEY (Owner) REFERENCES Principals(id);
12 ALTER TABLE Tickets ADD INDEX(Creator);
13 ALTER TABLE Tickets ADD INDEX(LastUpdatedBy);
14 ALTER TABLE Tickets ADD FOREIGN KEY (Creator) REFERENCES Users(id);
15 ALTER TABLE Tickets ADD FOREIGN KEY (LastUpdatedBy) REFERENCES Users(id);
16 ALTER TABLE Transactions ADD INDEX(Creator);
17 ALTER TABLE Transactions ADD INDEX (Ticket) ;
18 ALTER TABLE Transactions ADD INDEX (EffectiveTicket) ;
19 ALTER TABLE Transactions ADD FOREIGN KEY (Creator) REFERENCES Users(id);
20 ALTER TABLE Transactions ADD FOREIGN KEY (Ticket) REFERENCES Tickets(id);
21 ALTER TABLE Transactions ADD FOREIGN KEY (EffectiveTicket) REFERENCES Tickets(id);
22 ALTER TABLE Attachments ADD INDEX (TransactionId) ;
23 ALTER TABLE Attachments ADD INDEX (Parent) ;
24 ALTER TABLE Attachments ADD FOREIGN KEY (TransactionId) REFERENCES Transactions(id);
25 ALTER TABLE Attachments ADD FOREIGN KEY (Parent) REFERENCES Attachments(id);
26 ALTER TABLE Scrips ADD INDEX (ScripCondition) ;
27 ALTER TABLE Scrips ADD INDEX (ScripAction) ;
28 ALTER TABLE Scrips ADD INDEX (Template) ;
29 ALTER TABLE Scrips ADD INDEX (Queue) ;
30 ALTER TABLE Scrips ADD INDEX (Creator) ;
31 ALTER TABLE Scrips ADD INDEX (LastUpdatedBy) ;
32 ALTER TABLE Scrips ADD FOREIGN KEY (ScripCondition) REFERENCES ScripConditions(id);
33 ALTER TABLE Scrips ADD FOREIGN KEY (ScripAction) REFERENCES ScripActions(id);
34 ALTER TABLE Scrips ADD FOREIGN KEY (Template) REFERENCES Templates(id);
35 ALTER TABLE Scrips ADD FOREIGN KEY (Queue) REFERENCES Queues(id);
36 ALTER TABLE Scrips ADD FOREIGN KEY (Creator) REFERENCES Users(id);
37 ALTER TABLE Scrips ADD FOREIGN KEY (LastUpdatedBy) REFERENCES Users(id);
38 ALTER TABLE ACL ADD INDEX (PrincipalId) ;
39 ALTER TABLE ACL ADD INDEX (DelegatedBy) ;
40 ALTER TABLE ACL ADD INDEX (DelegatedFrom) ;
41 ALTER TABLE ACL ADD FOREIGN KEY (PrincipalId) REFERENCES Principals(id);
42 ALTER TABLE ACL ADD FOREIGN KEY (DelegatedBy) REFERENCES Principals(id);
43 ALTER TABLE ACL ADD FOREIGN KEY (DelegatedFrom) REFERENCES ACL(id);
44 ALTER TABLE GroupMembers ADD INDEX (MemberId);
45 ALTER TABLE GroupMembers ADD INDEX (GroupId);
46 ALTER TABLE GroupMembers ADD FOREIGN KEY (GroupId) REFERENCES Groups(id);
47 ALTER TABLE GroupMembers ADD FOREIGN KEY (MemberId) REFERENCES Principals(id);
48 ALTER TABLE CachedGroupMembers ADD INDEX (ImmediateParentId) ;
49 ALTER TABLE CachedGroupMembers ADD INDEX (GroupId) ;
50 ALTER TABLE CachedGroupMembers ADD INDEX (MemberId) ;
51 ALTER TABLE CachedGroupMembers ADD INDEX (Via) ;
52 ALTER TABLE CachedGroupMembers ADD FOREIGN KEY (ImmediateParentId) REFERENCES Principals(id);
53 ALTER TABLE CachedGroupMembers ADD FOREIGN KEY (GroupId) REFERENCES Principals(id);
54 ALTER TABLE CachedGroupMembers ADD FOREIGN KEY (MemberId) REFERENCES Principals(id);
55 ALTER TABLE CachedGroupMembers ADD FOREIGN KEY (Via) REFERENCES CachedGroupMembers(id);
56 ALTER TABLE ScripActions ADD INDEX(Creator);
57 ALTER TABLE ScripActions ADD INDEX(LastUpdatedBy);
58 ALTER TABLE ScripActions ADD FOREIGN KEY (Creator) REFERENCES Users(id);
59 ALTER TABLE ScripActions ADD FOREIGN KEY (LastUpdatedBy) REFERENCES Users(id);
60 ALTER TABLE Templates ADD INDEX(Queue);
61 ALTER TABLE Templates ADD INDEX(Creator);
62 ALTER TABLE Templates ADD INDEX(LastUpdatedBy);
63 ALTER TABLE Templates ADD FOREIGN KEY (Queue) REFERENCES Queues(id);
64 ALTER TABLE Templates ADD FOREIGN KEY (Creator) REFERENCES Users(id);
65 ALTER TABLE Templates ADD FOREIGN KEY (LastUpdatedBy) REFERENCES Users(id);
66 ALTER TABLE CustomFields ADD INDEX(Queue);
67 ALTER TABLE CustomFields ADD INDEX(Creator);
68 ALTER TABLE CustomFields ADD INDEX(LastUpdatedBy);
69 ALTER TABLE CustomFields ADD FOREIGN KEY (Queue) REFERENCES Queues(id);
70 ALTER TABLE CustomFields ADD FOREIGN KEY (Creator) REFERENCES Users(id);
71 ALTER TABLE CustomFields ADD FOREIGN KEY (LastUpdatedBy) REFERENCES Users(id);
72 ALTER TABLE TicketCustomFieldValues ADD INDEX(Ticket);
73 ALTER TABLE TicketCustomFieldValues ADD INDEX(CustomField);
74 ALTER TABLE TicketCustomFieldValues ADD INDEX(Creator);
75 ALTER TABLE TicketCustomFieldValues ADD INDEX(LastUpdatedBy);
76 ALTER TABLE TicketCustomFieldValues ADD FOREIGN KEY (Ticket) REFERENCES Tickets(id);
77 ALTER TABLE TicketCustomFieldValues ADD FOREIGN KEY (CustomField) REFERENCES CustomFields(id);
78 ALTER TABLE TicketCustomFieldValues ADD FOREIGN KEY (Creator) REFERENCES Users(id);
79 ALTER TABLE TicketCustomFieldValues ADD FOREIGN KEY (LastUpdatedBy) REFERENCES Users(id);
80 ALTER TABLE CustomFieldValues ADD INDEX(CustomField);
81 ALTER TABLE CustomFieldValues ADD INDEX(Creator);
82 ALTER TABLE CustomFieldValues ADD INDEX(LastUpdatedBy);
83 ALTER TABLE CustomFieldValues ADD FOREIGN KEY (CustomField) REFERENCES CustomFields(id);
84 ALTER TABLE CustomFieldValues ADD FOREIGN KEY (Creator) REFERENCES Users(id);
85 ALTER TABLE CustomFieldValues ADD FOREIGN KEY (LastUpdatedBy) REFERENCES Users(id);