import rt 3.4.4
[freeside.git] / rt / etc / schema.Pg
index a5b68b3..2d45a94 100755 (executable)
@@ -57,7 +57,7 @@ CREATE TABLE Queues (
   Created TIMESTAMP NULL  ,
   LastUpdatedBy integer NOT NULL DEFAULT 0  ,
   LastUpdated TIMESTAMP NULL  ,
-  Disabled int2 NOT NULL DEFAULT 0 ,
+  Disabled integer NOT NULL DEFAULT 0 ,
   PRIMARY KEY (id)
 
 );
@@ -108,7 +108,7 @@ CREATE TABLE Principals (
         id INTEGER DEFAULT nextval('principals_id_seq') not null,
         PrincipalType VARCHAR(16) not null,
         ObjectId integer, 
-        Disabled int2 NOT NULL DEFAULT 0 ,
+        Disabled integer NOT NULL DEFAULT 0 ,
         PRIMARY KEY (id)
 
 );
@@ -183,13 +183,16 @@ CREATE SEQUENCE transactions_id_seq;
 
 CREATE TABLE Transactions (
   id INTEGER DEFAULT nextval('transactions_id_seq'),
-  EffectiveTicket integer NOT NULL DEFAULT 0  ,
-  Ticket integer NOT NULL DEFAULT 0  ,
+  ObjectType varchar(255) NOT NULL  ,
+  ObjectId integer NOT NULL DEFAULT 0  ,
   TimeTaken integer NOT NULL DEFAULT 0  ,
   Type varchar(20) NULL  ,
   Field varchar(40) NULL  ,
   OldValue varchar(255) NULL  ,
   NewValue varchar(255) NULL  ,
+  ReferenceType varchar(255) NULL,
+  OldReference integer NULL  ,
+  NewReference integer NULL  ,
   Data varchar(255) NULL  ,
 
   Creator integer NOT NULL DEFAULT 0  ,
@@ -197,8 +200,7 @@ CREATE TABLE Transactions (
   PRIMARY KEY (id)
 
 );
-CREATE INDEX Transactions1 ON Transactions (Ticket);
-CREATE INDEX Transactions2 ON Transactions (EffectiveTicket);
+CREATE INDEX Transactions1 ON Transactions (ObjectType, ObjectId);
 
 -- }}}
 
@@ -299,7 +301,7 @@ CREATE TABLE CachedGroupMembers (
         MemberId int, 
         Via int, 
         ImmediateParentId int, 
-        Disabled int2 NOT NULL DEFAULT 0 , 
+        Disabled integer NOT NULL DEFAULT 0 , 
         PRIMARY KEY (id)
 
 );
@@ -406,7 +408,7 @@ CREATE TABLE Tickets (
   LastUpdated TIMESTAMP NULL  ,
   Creator integer NOT NULL DEFAULT 0  ,
   Created TIMESTAMP NULL  ,
-  Disabled int2 NOT NULL DEFAULT 0 ,
+  Disabled integer NOT NULL DEFAULT 0 ,
   PRIMARY KEY (id)
 
 );
@@ -474,7 +476,7 @@ CREATE TABLE Templates (
 
 -- }}}
 
--- {{{ TicketCustomFieldValues 
+-- {{{ ObjectCustomFieldValues 
 
 
 
@@ -482,24 +484,31 @@ CREATE TABLE Templates (
 -- Sequences for table TICKETCUSTOMFIELDVALUES
 --
 
-CREATE SEQUENCE ticketcustomfieldvalues_id_s;
+CREATE SEQUENCE objectcustomfieldvalues_id_s;
 
-CREATE TABLE TicketCustomFieldValues (
-  id INTEGER DEFAULT nextval('ticketcustomfieldvalues_id_s'),
-  Ticket int NOT NULL  ,
+CREATE TABLE ObjectCustomFieldValues (
+  id INTEGER DEFAULT nextval('objectcustomfieldvalues_id_s'),
   CustomField int NOT NULL  ,
+  ObjectType varchar(255) NULL  ,
+  ObjectId int NOT NULL  ,
+  SortOrder integer NOT NULL DEFAULT 0  ,
+
   Content varchar(255) NULL  ,
+  LargeContent text NULL,
+  ContentType varchar(80) NULL,
+  ContentEncoding varchar(80) NULL  ,
 
   Creator integer NOT NULL DEFAULT 0  ,
   Created TIMESTAMP NULL  ,
   LastUpdatedBy integer NOT NULL DEFAULT 0  ,
   LastUpdated TIMESTAMP NULL  ,
+  Disabled integer NOT NULL DEFAULT 0 ,
   PRIMARY KEY (id)
 
 );
 
-CREATE INDEX TicketCustomFieldValues1 ON TicketCustomFieldValues (CustomField,Ticket,Content); 
-CREATE INDEX TicketCustomFieldValues2 ON TicketCustomFieldValues (CustomField,Ticket); 
+CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId,Content); 
+CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId); 
 
 -- }}}
 
@@ -517,7 +526,10 @@ CREATE TABLE CustomFields (
   id INTEGER DEFAULT nextval('customfields_id_seq'),
   Name varchar(200) NULL  ,
   Type varchar(200) NULL  ,
-  Queue integer NOT NULL DEFAULT 0 ,
+  MaxValues integer NOT NULL DEFAULT 0  ,
+  Repeated integer NOT NULL DEFAULT 0 , 
+  Pattern varchar(255) NULL  ,
+  LookupType varchar(255) NOT NULL  ,
   Description varchar(255) NULL  ,
   SortOrder integer NOT NULL DEFAULT 0  ,
 
@@ -525,7 +537,27 @@ CREATE TABLE CustomFields (
   Created TIMESTAMP NULL  ,
   LastUpdatedBy integer NOT NULL DEFAULT 0  ,
   LastUpdated TIMESTAMP NULL  ,
-  Disabled int2 NOT NULL DEFAULT 0 ,
+  Disabled integer NOT NULL DEFAULT 0 ,
+  PRIMARY KEY (id)
+
+);
+
+-- }}}
+
+-- {{{ ObjectCustomFields 
+
+CREATE SEQUENCE objectcustomfields_id_s;
+
+CREATE TABLE ObjectCustomFields (
+  id INTEGER DEFAULT nextval('objectcustomfields_id_s'),
+  CustomField integer NOT NULL,
+  ObjectId integer NOT NULL,
+  SortOrder integer NOT NULL DEFAULT 0  ,
+
+  Creator integer NOT NULL DEFAULT 0  ,
+  Created TIMESTAMP NULL  ,
+  LastUpdatedBy integer NOT NULL DEFAULT 0  ,
+  LastUpdated TIMESTAMP NULL  ,
   PRIMARY KEY (id)
 
 );
@@ -573,7 +605,7 @@ CREATE TABLE Attributes (
   Content text,
   ContentType varchar(16),
   ObjectType varchar(64),
-  ObjectId integer, # foreign key to anything
+  ObjectId integer, 
   Creator integer NOT NULL DEFAULT 0  ,
   Created TIMESTAMP NULL  ,
   LastUpdatedBy integer NOT NULL DEFAULT 0  ,