[Rt-commit] rt branch, 5.0/increase-id-size-in-db, created. rt-5.0.0alpha1-14-gc92e1e61f8

Michel Rodriguez michel at bestpractical.com
Fri Mar 27 10:56:58 EDT 2020


The branch, 5.0/increase-id-size-in-db has been created
        at  c92e1e61f8096d90e1a1032891b16d62f3074e12 (commit)

- Log -----------------------------------------------------------------
commit c6d96d3d70d2316c6e17dba943eca9f123b0df4a
Author: michel <michel at bestpractical.com>
Date:   Mon Mar 2 18:42:43 2020 +0100

    Increase the size of id fields for transactions and attachments to bigint.
    
    Also increases the size of foreign keys to those tables.
    
    This commit covers MySQL and PostgreSQL.
    
    Note that for PostgreSQL, in the upgrade script, the ALTER TABLE statements
    only need to change the data type. Nullable and default properties keep
    their values.

diff --git a/etc/schema.Pg b/etc/schema.Pg
index eda93108df..a027d35056 100644
--- a/etc/schema.Pg
+++ b/etc/schema.Pg
@@ -14,9 +14,9 @@ CREATE SEQUENCE attachments_id_seq;
 
 
 CREATE TABLE Attachments (
-  id INTEGER DEFAULT nextval('attachments_id_seq'),
-  TransactionId integer NOT NULL  ,
-  Parent integer NOT NULL DEFAULT 0  ,
+  id BIGINT DEFAULT nextval('attachments_id_seq'),
+  TransactionId bigint NOT NULL  ,
+  Parent bigint NOT NULL DEFAULT 0  ,
   MessageId varchar(160) NULL  ,
   Subject varchar(255) NULL  ,
   Filename varchar(255) NULL  ,
@@ -184,7 +184,7 @@ CREATE TABLE ScripConditions (
 CREATE SEQUENCE transactions_id_seq;
 
 CREATE TABLE Transactions (
-  id INTEGER DEFAULT nextval('transactions_id_seq'),
+  id BIGINT DEFAULT nextval('transactions_id_seq'),
   ObjectType varchar(255) NOT NULL  ,
   ObjectId integer NOT NULL DEFAULT 0  ,
   TimeTaken integer NOT NULL DEFAULT 0  ,
@@ -497,7 +497,7 @@ CREATE TABLE ObjectCustomFieldValues (
   id INTEGER DEFAULT nextval('objectcustomfieldvalues_id_s'),
   CustomField int NOT NULL  ,
   ObjectType varchar(255) NULL  ,
-  ObjectId int NOT NULL  ,
+  ObjectId bigint NOT NULL  ,
   SortOrder integer NOT NULL DEFAULT 0  ,
 
   Content varchar(255) NULL  ,
diff --git a/etc/schema.mysql b/etc/schema.mysql
index b0b374c736..706ba25137 100644
--- a/etc/schema.mysql
+++ b/etc/schema.mysql
@@ -1,8 +1,8 @@
 
 CREATE TABLE Attachments (
-  id INTEGER NOT NULL  AUTO_INCREMENT,
-  TransactionId integer NOT NULL  ,
-  Parent integer NOT NULL DEFAULT 0  ,
+  id BIGINT NOT NULL  AUTO_INCREMENT,
+  TransactionId BIGINT NOT NULL  ,
+  Parent BIGINT NOT NULL DEFAULT 0  ,
   MessageId varchar(160) CHARACTER SET ascii NULL  ,
   Subject varchar(255) NULL  ,
   Filename varchar(255) NULL  ,
@@ -103,7 +103,7 @@ CREATE TABLE ScripConditions (
 
 
 CREATE TABLE Transactions (
-  id INTEGER NOT NULL  AUTO_INCREMENT,
+  id BIGINT NOT NULL  AUTO_INCREMENT,
   ObjectType varchar(64) CHARACTER SET ascii NOT NULL,
   ObjectId integer NOT NULL DEFAULT 0  ,
   TimeTaken integer NOT NULL DEFAULT 0  ,
@@ -326,7 +326,7 @@ CREATE TABLE ObjectCustomFieldValues (
   id INTEGER NOT NULL  AUTO_INCREMENT,
   CustomField int NOT NULL  ,
   ObjectType varchar(255) CHARACTER SET ascii NOT NULL,     # Final target of the Object
-  ObjectId int NOT NULL  ,                  # New -- Replaces Ticket
+  ObjectId BIGINT NOT NULL  ,                  # New -- Replaces Ticket
   SortOrder integer NOT NULL DEFAULT 0  ,   # New -- ordering for multiple values
 
   Content varchar(255) NULL  ,
diff --git a/etc/upgrade/4.5.4/schema.Pg b/etc/upgrade/4.5.4/schema.Pg
new file mode 100644
index 0000000000..381b06ec26
--- /dev/null
+++ b/etc/upgrade/4.5.4/schema.Pg
@@ -0,0 +1,5 @@
+ALTER TABLE Attachments ALTER COLUMN id SET DATA TYPE BIGINT;
+ALTER TABLE Attachments ALTER COLUMN TransactionId SET DATA TYPE BIGINT;
+ALTER TABLE Attachments ALTER COLUMN Parent SET DATA TYPE BIGINT;
+ALTER TABLE Transactions ALTER COLUMN id SET DATA TYPE BIGINT;
+ALTER TABLE ObjectCustomFieldValues ALTER COLUMN ObjectId SET DATA TYPE BIGINT;
diff --git a/etc/upgrade/4.5.4/schema.mysql b/etc/upgrade/4.5.4/schema.mysql
new file mode 100644
index 0000000000..2f0d7a76d3
--- /dev/null
+++ b/etc/upgrade/4.5.4/schema.mysql
@@ -0,0 +1,5 @@
+ALTER TABLE Attachments MODIFY id BIGINT NOT NULL AUTO_INCREMENT;
+ALTER TABLE Attachments MODIFY TransactionId BIGINT NOT NULL;
+ALTER TABLE Attachments MODIFY Parent BIGINT NOT NULL DEFAULT 0;
+ALTER TABLE Transactions MODIFY id BIGINT NOT NULL AUTO_INCREMENT;
+ALTER TABLE ObjectCustomFieldValues MODIFY ObjectId BIGINT NOT NULL;

commit cf531b24ef07843bbd7912676daf551b27c77a39
Author: michel <michel at bestpractical.com>
Date:   Mon Mar 2 21:24:53 2020 +0100

    Increase the size of id fields for transactions and attachments to number(19,0).
    
    Oracle does not have a bigint data type, number(19,0) is the equivalent.
    
    This commit has not been tested.

diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index b71b41d9d4..611e37a927 100644
--- a/etc/schema.Oracle
+++ b/etc/schema.Oracle
@@ -1,10 +1,10 @@
 
 CREATE SEQUENCE ATTACHMENTS_seq;
 CREATE TABLE Attachments (
-        id              NUMBER(11,0) 
+        id              NUMBER(19,0) 
                         CONSTRAINT Attachments_Key PRIMARY KEY,
-        TransactionId   NUMBER(11,0) NOT NULL,
-        Parent          NUMBER(11,0) DEFAULT 0 NOT NULL, 
+        TransactionId   NUMBER(19,0) NOT NULL,
+        Parent          NUMBER(19,0) DEFAULT 0 NOT NULL, 
         MessageId       VARCHAR2(160),
         Subject         VARCHAR2(255),
         Filename        VARCHAR2(255),
@@ -106,7 +106,7 @@ CREATE TABLE ScripConditions (
 
 CREATE SEQUENCE TRANSACTIONS_seq;
 CREATE TABLE Transactions (
-        id                      NUMBER(11,0) 
+        id                      NUMBER(19,0) 
                 CONSTRAINT Transactions_Key PRIMARY KEY,
         ObjectType              VARCHAR2(255),
         ObjectId                NUMBER(11,0) DEFAULT 0 NOT NULL,
@@ -327,7 +327,7 @@ CREATE TABLE ObjectCustomFieldValues (
                 CONSTRAINT ObjectCustomFieldValues_Key PRIMARY KEY,
         CustomField     NUMBER(11,0) NOT NULL,
         ObjectType      VARCHAR2(25) NOT NULL,
-        ObjectId        NUMBER(11,0) DEFAULT 0 NOT NULL,
+        ObjectId        NUMBER(19,0) DEFAULT 0 NOT NULL,
         SortOrder       NUMBER(11,0) DEFAULT 0 NOT NULL,
         Content         VARCHAR2(255),
         LargeContent    CLOB,
diff --git a/etc/upgrade/4.5.4/schema.Oracle b/etc/upgrade/4.5.4/schema.Oracle
new file mode 100644
index 0000000000..6050d76b31
--- /dev/null
+++ b/etc/upgrade/4.5.4/schema.Oracle
@@ -0,0 +1,5 @@
+ALTER TABLE Attachments MODIFY id            NUMBER(19,0);
+ALTER TABLE Attachments MODIFY TransactionId NUMBER(19,0);
+ALTER TABLE Attachments MODIFY Parent        NUMBER(19,0);
+ALTER TABLE Transactions MODIFY id           NUMBER(19,0);
+ALTER TABLE ObjectCustomFieldValues MODIFY ObjectId NUMBER(19,0);

commit c92e1e61f8096d90e1a1032891b16d62f3074e12
Author: michel <michel at bestpractical.com>
Date:   Tue Mar 24 12:36:16 2020 +0100

    Update _CoreAccessible and pod with the new id size.

diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index 66a0e4e6d1..e75aec6f5e 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -1035,7 +1035,7 @@ sub _CacheConfig {
 =head2 id
 
 Returns the current value of id.
-(In the database, id is stored as int(11).)
+(In the database, id is stored as int(19).)
 
 
 =cut
@@ -1044,7 +1044,7 @@ Returns the current value of id.
 =head2 TransactionId
 
 Returns the current value of TransactionId.
-(In the database, TransactionId is stored as int(11).)
+(In the database, TransactionId is stored as int(19).)
 
 
 
@@ -1053,7 +1053,7 @@ Returns the current value of TransactionId.
 
 Set TransactionId to VALUE.
 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, TransactionId will be stored as a int(11).)
+(In the database, TransactionId will be stored as a int(19).)
 
 
 =cut
@@ -1062,7 +1062,7 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
 =head2 Parent
 
 Returns the current value of Parent.
-(In the database, Parent is stored as int(11).)
+(In the database, Parent is stored as int(19).)
 
 
 
@@ -1071,7 +1071,7 @@ Returns the current value of Parent.
 
 Set Parent to VALUE.
 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, Parent will be stored as a int(11).)
+(In the database, Parent will be stored as a int(19).)
 
 
 =cut
@@ -1226,11 +1226,11 @@ sub _CoreAccessible {
     {
 
         id =>
-                {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
+                {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(19)', default => ''},
         TransactionId =>
-                {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
+                {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(19)', default => ''},
         Parent =>
-                {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
+                {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(19)', default => '0'},
         MessageId =>
                 {read => 1, write => 1, sql_type => 12, length => 160,  is_blob => 0,  is_numeric => 0,  type => 'varchar(160)', default => ''},
         Subject =>
diff --git a/lib/RT/ObjectCustomFieldValue.pm b/lib/RT/ObjectCustomFieldValue.pm
index 88740fc1f4..a331d0d889 100644
--- a/lib/RT/ObjectCustomFieldValue.pm
+++ b/lib/RT/ObjectCustomFieldValue.pm
@@ -576,7 +576,7 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
 =head2 ObjectId
 
 Returns the current value of ObjectId.
-(In the database, ObjectId is stored as int(11).)
+(In the database, ObjectId is stored as int(19).)
 
 
 
@@ -585,7 +585,7 @@ Returns the current value of ObjectId.
 
 Set ObjectId to VALUE.
 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
-(In the database, ObjectId will be stored as a int(11).)
+(In the database, ObjectId will be stored as a int(19).)
 
 
 =cut
@@ -746,7 +746,7 @@ sub _CoreAccessible {
         ObjectType =>
                 {read => 1, write => 1, sql_type => 12, length => 255,  is_blob => 0,  is_numeric => 0,  type => 'varchar(255)', default => ''},
         ObjectId =>
-                {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
+                {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(19)', default => ''},
         SortOrder =>
                 {read => 1, write => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => '0'},
         Content =>
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 914fe51caf..d1145a6383 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -1762,7 +1762,7 @@ sub ACLEquivalenceObjects {
 =head2 id
 
 Returns the current value of id.
-(In the database, id is stored as int(11).)
+(In the database, id is stored as int(19).)
 
 
 =cut
@@ -1989,7 +1989,7 @@ sub _CoreAccessible {
     {
 
         id =>
-                {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(11)', default => ''},
+                {read => 1, sql_type => 4, length => 11,  is_blob => 0,  is_numeric => 1,  type => 'int(19)', default => ''},
         ObjectType =>
                 {read => 1, write => 1, sql_type => 12, length => 64,  is_blob => 0,  is_numeric => 0,  type => 'varchar(64)', default => ''},
         ObjectId =>

-----------------------------------------------------------------------


More information about the rt-commit mailing list