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
|
alter Table Transactions ADD Column (ObjectType varchar(64) not null);
update Transactions set ObjectType = 'RT::Ticket';
alter table Transactions drop column EffectiveTicket;
alter table Transactions add column ReferenceType varchar(255) NULL;
alter table Transactions add column OldReference integer NULL;
alter table Transactions add column NewReference integer NULL;
alter table Transactions drop index transactions1;
alter table Transactions change Ticket ObjectId integer NOT NULL DEFAULT 0 ;
CREATE INDEX Transactions1 ON Transactions (ObjectType, ObjectId);
alter table TicketCustomFieldValues rename ObjectCustomFieldValues;
alter table ObjectCustomFieldValues change Ticket ObjectId integer NOT NULL DEFAULT 0 ;
alter table ObjectCustomFieldValues add column ObjectType varchar(255) not null;
update ObjectCustomFieldValues set ObjectType = 'RT::Ticket';
alter table ObjectCustomFieldValues add column Current bool default 1;
alter table ObjectCustomFieldValues add column LargeContent LONGTEXT NULL;
alter table ObjectCustomFieldValues add column ContentType varchar(80) NULL;
alter table ObjectCustomFieldValues add column ContentEncoding varchar(80) NULL;
# These could fail if there's no such index and there's no "drop index if exists" syntax
#alter table ObjectCustomFieldValues drop index ticketcustomfieldvalues1;
#alter table ObjectCustomFieldValues drop index ticketcustomfieldvalues2;
alter table ObjectCustomFieldValues add index ObjectCustomFieldValues1 (Content);
alter table ObjectCustomFieldValues add index ObjectCustomFieldValues2 (CustomField,ObjectType,ObjectId);
CREATE TABLE ObjectCustomFields (
id INTEGER NOT NULL AUTO_INCREMENT,
CustomField int NOT NULL ,
ObjectId integer NOT NULL,
SortOrder integer NOT NULL DEFAULT 0 ,
Creator integer NOT NULL DEFAULT 0 ,
Created DATETIME NULL ,
LastUpdatedBy integer NOT NULL DEFAULT 0 ,
LastUpdated DATETIME NULL ,
PRIMARY KEY (id)
) TYPE=InnoDB;
INSERT into ObjectCustomFields (id, CustomField, ObjectId, SortOrder, Creator, LastUpdatedBy) SELECT null, id, Queue, SortOrder, Creator, LastUpdatedBy from CustomFields;
alter table CustomFields add column LookupType varchar(255) NOT NULL;
alter table CustomFields add column Repeated int2 NOT NULL DEFAULT 0 ;
alter table CustomFields add column Pattern varchar(255) NULL;
alter table CustomFields add column MaxValues integer;
# See above
# alter table CustomFields drop index CustomFields1;
UPDATE CustomFields SET MaxValues = 0 WHERE Type LIKE '%Multiple';
UPDATE CustomFields SET MaxValues = 1 WHERE Type LIKE '%Single';
UPDATE CustomFields SET Type = 'Select' WHERE Type LIKE 'Select%';
UPDATE CustomFields SET Type = 'Freeform' WHERE Type LIKE 'Freeform%';
UPDATE CustomFields Set LookupType = 'RT::Queue-RT::Ticket';
alter table CustomFields drop column Queue;
|