[Rt-commit] r5215 - in rt/branches/3.5-EXPERIMENTAL-MYSQL-UPDATES: .

ruz at bestpractical.com ruz at bestpractical.com
Fri May 12 16:25:15 EDT 2006


Author: ruz
Date: Fri May 12 16:25:13 2006
New Revision: 5215

Modified:
   rt/branches/3.5-EXPERIMENTAL-MYSQL-UPDATES/   (props changed)
   rt/branches/3.5-EXPERIMENTAL-MYSQL-UPDATES/sbin/rt-setup-database.in

Log:
 r2878 at cubic-pc:  cubic | 2006-05-13 00:31:43 +0400
 * add check_db_compatibility function


Modified: rt/branches/3.5-EXPERIMENTAL-MYSQL-UPDATES/sbin/rt-setup-database.in
==============================================================================
--- rt/branches/3.5-EXPERIMENTAL-MYSQL-UPDATES/sbin/rt-setup-database.in	(original)
+++ rt/branches/3.5-EXPERIMENTAL-MYSQL-UPDATES/sbin/rt-setup-database.in	Fri May 12 16:25:13 2006
@@ -103,23 +103,7 @@
         print "...skipped as ".$args{'dba'} ." is not " . $RT::DatabaseUser . " or we're working with Oracle.\n";
     }
 
-    if ( $RT::DatabaseType eq "mysql" ) {
-        # Check which version we're running
-        my ($version) = $dbh->selectrow_hashref("show variables like 'version'")->{Value} =~ /^(\d\.\d+)/;
-        print "*** Warning: RT is unsupported on MySQL versions before 4.0.x\n" if $version < 4;
-
-        # MySQL must have InnoDB support
-        my $innodb = $dbh->selectrow_hashref("show variables like 'have_innodb'")->{Value};
-        if ( $innodb eq "NO" ) {
-            die "RT requires that MySQL be compiled with InnoDB table support.\n".
-              "See http://dev.mysql.com/doc/mysql/en/InnoDB.html\n";
-        } elsif ( $innodb eq "DISABLED" ) {
-            die "RT requires that MySQL InnoDB table support be enabled.\n".
-              ($version < 4
-               ? "Add 'innodb_data_file_path=ibdata1:10M:autoextend' to the [mysqld] section of my.cnf\n"
-               : "Remove the 'skip-innodb' line from your my.cnf file, restart MySQL, and try again.\n");
-        }
-    }
+    check_db_compatibility();
 
     # SQLite can't deal with the disconnect/reconnect
     unless ( $RT::DatabaseType eq 'SQLite' ) {
@@ -146,6 +130,8 @@
     drop_db();
 }
 elsif ( $args{'action'} eq 'insert' ) {
+    $dbh = get_rt_dbh();
+    check_db_compatibility();
     insert_data( $args{'datafile'} || ($args{'datadir'}."/content") );
 }
 elsif ( $args{'action'} eq 'acl' ) {
@@ -154,6 +140,7 @@
 }
 elsif ( $args{'action'} eq 'schema' ) {
     $dbh = get_rt_dbh( $args{'dba'}, $args{'dba-password'} );
+    check_db_compatibility();
     insert_schema($args{'datadir'});
 }
 else {
@@ -549,6 +536,51 @@
     print "Done setting up database content.\n";
 }
 
+sub check_db_compatibility {
+    if ( $RT::DatabaseType eq "mysql" ) {
+        # Check which version we're running
+        my ($version) = $dbh->selectrow_hashref("show variables like 'version'")->{Value} =~ /^(\d\.\d+)/;
+        if ( $version < 4 ) {
+            print STDERR "*** WARNING: RT is unsupported on MySQL versions before 4.0.x\n";
+        }
+
+        # MySQL must have InnoDB support
+        if ( $args{'action'} =~ /^(init|insert|schema)$/ ) {
+            print "Checking that mysql has spport for InnoDB.\n" if $args{'debug'};
+            my $innodb = $dbh->selectrow_hashref("show variables like 'have_innodb'")->{Value};
+            if ( $innodb eq "NO" ) {
+                print STDERR "RT requires that MySQL be compiled with InnoDB table support.\n".
+                  "See http://dev.mysql.com/doc/mysql/en/InnoDB.html\n";
+                exit -1;
+            } elsif ( $innodb eq "DISABLED" ) {
+                print STDERR "RT requires that MySQL InnoDB table support be enabled.\n".
+                  ($version < 4
+                   ? "Add 'innodb_data_file_path=ibdata1:10M:autoextend' to the [mysqld] section of my.cnf\n"
+                   : "Remove the 'skip-innodb' line from your my.cnf file, restart MySQL, and try again.\n");
+                exit -1;
+            }
+        }
+        if ( $args{'action'} =~ /^(insert|schema)$/ ) {
+            print "Checking that Tickets table is of InnoDB type.\n" if $args{'debug'};
+            my $create_table = $dbh->selectrow_arrayref("SHOW CREATE TABLE Tickets")->[1];
+            unless ( $create_table =~ /ENGINE=InnoDB/ ) {
+                print STDERR 'RT requires that all its tables be of InnoDB type.\n'.
+                    "Upgrade RT tables.\n";
+                exit -1;
+            }
+        }
+        if ( $version >= 4.1 && $args{'action'} =~ /^(insert|schema)$/ ) {
+            print "MySQL >= 4.1, checking that user upgraded.\n" if $args{'debug'};
+            my $create_table = $dbh->selectrow_arrayref("SHOW CREATE TABLE Attachments")->[1];
+            unless ( $create_table =~ /\bContent\b[^,]*BLOB/i ) {
+                print STDERR "*** WARNING: RT since version 3.6 has new schema for MySQL versions after 4.1.0\n"
+                    ."Follow instructions in the UPGRADING.mysql file.\n";
+                sleep 3;
+            }
+        }
+    }
+}
+
 sub get_dba_password {
     print "In order to create or update your RT database,";
     print "this script needs to connect to your "


More information about the Rt-commit mailing list