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

Michel Rodriguez michel at bestpractical.com
Mon Mar 2 15:51:01 EST 2020


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

- Log -----------------------------------------------------------------
commit efd915fe3de911a1f88391cd8beec6506e73c9d4
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 eda93108d..a027d3505 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 b0b374c73..f342baa5c 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  ,
diff --git a/etc/upgrade/4.5.4/schema.Pg b/etc/upgrade/4.5.4/schema.Pg
new file mode 100644
index 000000000..381b06ec2
--- /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 000000000..2f0d7a76d
--- /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 adf47ce397794492a8474c4ee8aacbae7e19d1bf
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 b71b41d9d..611e37a92 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 000000000..9be1064ac
--- /dev/null
+++ b/etc/upgrade/4.5.4/schema.Oracle
@@ -0,0 +1,5 @@
+ALTER TABLE Attachments MODIFY id            NUMBER(19,0) CONSTRAINT Attachments_Key PRIMARY KEY;
+ALTER TABLE Attachments MODIFY TransactionId NUMBER(19,0) NOT NULL;
+ALTER TABLE Attachments MODIFY Parent        NUMBER(19,0) DEFAULT 0 NOT NULL;
+ALTER TABLE Transactions MODIFY id NUMBER(19,0) CONSTRAINT Transactions_Key PRIMARY KEY;
+ALTER TABLE ObjectCustomFieldValues MODIFY ObjectId NUMBER(19,0) DEFAULT 0 NOT NULL;

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


More information about the rt-commit mailing list