[Rt-commit] rt branch, 5.0.0-releng, updated. rt-5.0.0beta2-61-g2b1b9f286c

Jim Brandt jbrandt at bestpractical.com
Fri Jul 10 14:51:02 EDT 2020


The branch, 5.0.0-releng has been updated
       via  2b1b9f286c9f3822bcaabbf3d172812edcbcc70c (commit)
       via  ca5918728b218f21f60eb5772f3930c4a91f696b (commit)
       via  54723410b677b9cfa1905099287dc6692d207fae (commit)
       via  ae053a358159d62aede076cb731ff04e960f5a83 (commit)
      from  72794f112630bfa59e58ebcf9483a2c2a70a4a39 (commit)

Summary of changes:
 etc/upgrade/4.5.8/content       | 20 ++++++++++++++++++++
 lib/RT/Handle.pm                |  5 +++--
 sbin/rt-setup-database.in       |  2 +-
 sbin/rt-setup-fulltext-index.in |  4 ++--
 4 files changed, 26 insertions(+), 5 deletions(-)
 create mode 100644 etc/upgrade/4.5.8/content

- Log -----------------------------------------------------------------
commit ae053a358159d62aede076cb731ff04e960f5a83
Author: Aaron Trevena <ast at bestpractical.com>
Date:   Fri Jul 10 07:32:17 2020 +0100

    Update id column in full text search table to BIGINT
    
    The id column in the AttachmentsIndex table maps to
    id from Attachments, which was also updated to BIGINT
    in c6d96d3d70.

diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index bca79156b4..f12bc6b552 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -178,7 +178,7 @@ if ( $DB{'type'} eq 'mysql' ) {
 
     my $engine = $RT::Handle->dbh->{mysql_serverversion} < 50600 ? "MyISAM" : "InnoDB";
     my $schema = "CREATE TABLE $table ( "
-        ."id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,"
+        ."id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,"
         ."Content LONGTEXT ) ENGINE=$engine CHARACTER SET utf8mb4";
     insert_schema( $schema );
 
@@ -326,7 +326,7 @@ elsif ( $DB{'type'} eq 'Pg' ) {
         $drop = "DROP TABLE $table";
         push @schema, split /;\n+/, <<SCHEMA;
 CREATE TABLE $table (
-    id SERIAL,
+    id BIGSERIAL,
     $column tsvector
 );
 GRANT SELECT, INSERT, UPDATE, DELETE ON $table TO "$DB{user}"

commit 54723410b677b9cfa1905099287dc6692d207fae
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Jul 9 21:18:15 2020 +0800

    Pass admin dbh to @Initial and @Final blocks for upgrade
    
    The initial reason is we want to alter fulltext search table for the
    bigint/utf8mb4 schema change, which requires admin database handle.

diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 3fd9b52974..fc003ca594 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -846,6 +846,7 @@ sub InsertData {
     my $root_password = shift;
     my %args     = (
         disconnect_after => 1,
+        admin_dbh        => undef,
         @_
     );
 
@@ -925,7 +926,7 @@ sub InsertData {
         $RT::Logger->debug("Running initial actions...");
         foreach ( @Initial ) {
             local $@;
-            eval { $_->(); 1 } or return (0, "One of initial functions failed: $@");
+            eval { $_->( admin_dbh => $args{admin_dbh} ); 1 } or return (0, "One of initial functions failed: $@");
         }
         $RT::Logger->debug("Done.");
     }
@@ -1850,7 +1851,7 @@ sub InsertData {
         $RT::Logger->debug("Running final actions...");
         for ( @Final ) {
             local $@;
-            eval { $_->(); };
+            eval { $_->( admin_dbh => $args{admin_dbh} ); };
             $RT::Logger->error( "Failed to run one of final actions: $@" )
                 if $@;
         }
diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index 38e658544e..18a27b2b6e 100644
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -390,7 +390,7 @@ sub action_insert {
 
     my @ret;
 
-    my $upgrade = sub { @ret = $RT::Handle->InsertData( $file, $root_password ) };
+    my $upgrade = sub { @ret = $RT::Handle->InsertData( $file, $root_password, admin_dbh => get_admin_dbh() ) };
 
     for my $file (@{$args{backcompat} || []}) {
         my $lines = do {local $/; local @ARGV = ($file); <>};

commit ca5918728b218f21f60eb5772f3930c4a91f696b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Jul 9 21:53:24 2020 +0800

    Add upgrade step to update full text search table schema for bigint/utf8mb4

diff --git a/etc/upgrade/4.5.8/content b/etc/upgrade/4.5.8/content
new file mode 100644
index 0000000000..c9d9a40ab5
--- /dev/null
+++ b/etc/upgrade/4.5.8/content
@@ -0,0 +1,20 @@
+use strict;
+use warnings;
+
+our @Final = sub {
+    my %args = @_;
+    my $db_type = RT->Config->Get('DatabaseType');
+    return unless $db_type =~ /Pg|mysql/;
+
+    my $fts_config = RT->Config->Get('FullTextSearch') or return;
+    return unless $fts_config->{'Enable'} && $fts_config->{'Indexed'};
+
+    my $sql;
+    if ( $db_type eq 'Pg' ) {
+        $sql = "ALTER TABLE $fts_config->{'Table'} ALTER COLUMN id SET DATA TYPE BIGINT";
+    }
+    else {
+        $sql = "ALTER TABLE $fts_config->{'Table'} MODIFY id BIGINT NOT NULL AUTO_INCREMENT, CONVERT TO CHARACTER SET utf8mb4";
+    }
+    $args{admin_dbh}->do($sql) or warn "Couldn't run SQL query: $sql: " . $args{admin_dbh}->errstr;
+};

commit 2b1b9f286c9f3822bcaabbf3d172812edcbcc70c
Merge: 72794f1126 ca5918728b
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Fri Jul 10 14:38:43 2020 -0400

    Merge branch '5.0/update-full-text-search-table-schema' into 5.0.0-releng


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


More information about the rt-commit mailing list