starting to work...
[freeside.git] / rt / etc / upgrade / 3.3.0 / schema.mysql
1 alter Table Transactions ADD Column (ObjectType varchar(64) not null);
2 update Transactions set ObjectType = 'RT::Ticket';
3 alter table Transactions drop column EffectiveTicket;
4 alter table Transactions add column ReferenceType varchar(255) NULL;
5 alter table Transactions add column OldReference integer NULL;      
6 alter table Transactions add column NewReference integer NULL;
7 alter table Transactions drop index transactions1;            
8 alter table Transactions change Ticket ObjectId integer NOT NULL DEFAULT 0  ;
9
10 CREATE INDEX Transactions1 ON Transactions (ObjectType, ObjectId);
11
12 alter table TicketCustomFieldValues rename ObjectCustomFieldValues;
13
14 alter table ObjectCustomFieldValues  change Ticket ObjectId integer NOT NULL DEFAULT 0  ;
15
16 alter table ObjectCustomFieldValues add column ObjectType varchar(255) not null;
17
18 update ObjectCustomFieldValues set ObjectType = 'RT::Ticket';
19
20 alter table ObjectCustomFieldValues add column Current bool default 1;  
21
22 alter table ObjectCustomFieldValues add column LargeContent LONGTEXT NULL;
23
24 alter table ObjectCustomFieldValues add column ContentType varchar(80) NULL;
25
26 alter table ObjectCustomFieldValues add column ContentEncoding varchar(80) NULL;
27
28 # These could fail if there's no such index and there's no "drop index if exists" syntax
29 #alter table ObjectCustomFieldValues drop index ticketcustomfieldvalues1;
30 #alter table ObjectCustomFieldValues drop index ticketcustomfieldvalues2;
31
32 alter table ObjectCustomFieldValues add index ObjectCustomFieldValues1 (Content); 
33
34 alter table ObjectCustomFieldValues add index ObjectCustomFieldValues2 (CustomField,ObjectType,ObjectId); 
35
36
37 CREATE TABLE ObjectCustomFields (
38   id INTEGER NOT NULL  AUTO_INCREMENT,
39   CustomField int NOT NULL  ,
40   ObjectId integer NOT NULL,
41   SortOrder integer NOT NULL DEFAULT 0  ,
42
43   Creator integer NOT NULL DEFAULT 0  ,
44   Created DATETIME NULL  ,
45   LastUpdatedBy integer NOT NULL DEFAULT 0  ,
46   LastUpdated DATETIME NULL  ,
47   PRIMARY KEY (id)
48 ) ENGINE=InnoDB;
49
50
51 INSERT into ObjectCustomFields (id, CustomField, ObjectId, SortOrder, Creator, LastUpdatedBy) SELECT  null, id, Queue, SortOrder, Creator, LastUpdatedBy from CustomFields;
52
53 alter table CustomFields add column LookupType varchar(255) NOT NULL;
54 alter table CustomFields add column Repeated int2 NOT NULL DEFAULT 0 ;
55 alter table CustomFields add column Pattern varchar(255) NULL;
56 alter table CustomFields add column MaxValues integer;
57 # See above
58 # alter table CustomFields drop index CustomFields1;
59
60 UPDATE CustomFields SET MaxValues = 0 WHERE Type LIKE '%Multiple';
61 UPDATE CustomFields SET MaxValues = 1 WHERE Type LIKE '%Single';
62 UPDATE CustomFields SET Type = 'Select' WHERE Type LIKE 'Select%';
63 UPDATE CustomFields SET Type = 'Freeform' WHERE Type LIKE 'Freeform%';
64 UPDATE CustomFields Set LookupType = 'RT::Queue-RT::Ticket';
65 alter table CustomFields drop column Queue;