[Rt-commit] r15021 - in rt/3.8/branches/3.8.1-releng: . sbin

falcone at bestpractical.com falcone at bestpractical.com
Mon Aug 11 19:36:25 EDT 2008


Author: falcone
Date: Mon Aug 11 19:36:24 2008
New Revision: 15021

Modified:
   rt/3.8/branches/3.8.1-releng/   (props changed)
   rt/3.8/branches/3.8.1-releng/UPGRADING.mysql
   rt/3.8/branches/3.8.1-releng/lib/RT/Plugin.pm
   rt/3.8/branches/3.8.1-releng/sbin/rt-setup-database.in

Log:
- Merge //mirror/bps-public/rt/3.8/trunk to //mirror/bps-public/rt/3.8/branches/3.8.1-releng

Modified: rt/3.8/branches/3.8.1-releng/UPGRADING.mysql
==============================================================================
--- rt/3.8/branches/3.8.1-releng/UPGRADING.mysql	(original)
+++ rt/3.8/branches/3.8.1-releng/UPGRADING.mysql	Mon Aug 11 19:36:24 2008
@@ -3,13 +3,22 @@
 breakage, image custom fields breakage and other.
 
 In order to resolve this issue we've changed our schema for mysql 4.1 and greater
-versions. If you're installing new RT then you can skip this file, but if
-you're upgrading from 4.0 then you MUST follow instructions below.
+versions.
+
+If you're installing new RT then you can skip this file.
+
+If you're migrating from MySQL 4.0 to MySQL 4.1 and newer then you MUST follow
+instructions at the bottom of this file.
+
+If you're upgrading RT from versions prior to 3.8.0 then you MUST follow
+instructions below.
+
+=== Upgrading RT from versions prior to 3.8.0 ===
 
 1) Backup RT database. It's really good to test that you can restore from
    this backup.
 
-2) Follow instructions in the README file to the step 7)
+2) Follow instructions in the README file to the step 7).
 
 3) Apply changes described in the seven step, but only up to version 3.8.0.
 
@@ -19,7 +28,7 @@
 
     perl etc/upgrade/schema.mysql-4.0-4.1.pl db user pass > sql.queries
 
-5) Check sanity of sql queries or consult with your DBA
+5) Check sanity of sql queries yourself or consult with your DBA
 
 6) Apply queries. Note that this step can take a while. May require additional
    space on your hard drive comparable with size of your tables.
@@ -41,3 +50,33 @@
 * binary custom fields
 * everything that may contain not ascii characters
 
+=== Migrating from MySQL 4.0 to MySQL 4.1 and newer ===
+
+Many people want to do migrate from one server and upgrade RT in one step
+what is really not that good idea as become more complicated, more time consuming,
+more chances to fail, much harder to debug.
+
+It's better to split in two steps. At first upgrade mysql from 4.0 to 4.1 or newer.
+Test for a while that everything works just fine. There are some rules you must
+remeber in this case:
+
+* don't use utf8 as default mysql's character set, it's default in some
+  distributives
+* import/export mysql dumps using binary character set
+
+When you're sure that everything is fine. You can upgrade RT using instructions
+above.
+
+If you still want to make upgrade of mysql and RT at once, then you can do the
+following:
+
+1) Install new RT on mysql 4.1 or newer.
+2) Test that this new clean RT works on this new DB server.
+3) Dump DB from mysql 4.0.
+4) Configure mysql 4.1 and newer to use latin1 as default character set
+   everywhere.
+5) Import dump into new mysql server replacing your empty DB you created
+   at step 1.
+6) At this point you have RT 3.8.x code base pointing to not upraged DB then
+   you can upgrade RT using instructions above.
+

Modified: rt/3.8/branches/3.8.1-releng/lib/RT/Plugin.pm
==============================================================================
--- rt/3.8/branches/3.8.1-releng/lib/RT/Plugin.pm	(original)
+++ rt/3.8/branches/3.8.1-releng/lib/RT/Plugin.pm	Mon Aug 11 19:36:24 2008
@@ -60,7 +60,8 @@
 
 =head2 new
 
-Instantiate a new RT::Plugin object. Takes a paramhash. currently the only key it cares about is 'name', the name of this plugin.
+Instantiate a new L<RT::Plugin> object. Takes a paramhash. currently the only key
+it cares about is 'name', the name of this plugin.
 
 =cut
 
@@ -83,26 +84,37 @@
     return $self->{name};
 }
 
+=head2 Path
+
+Takes a name of sub directory and returns its full path, for example:
+
+    my $plugin_etc_dir = $plugin->Path('etc');
+
+See also L</ComponentRoot>, L</PoDir> and other shortcut methods.
+
+=cut
+
+sub Path {
+    my $self = shift;
+    my $sub  = shift;
+    return $self->_BasePath ."/$sub";
+}
+
 sub _BasePath {
     my $self = shift;
     my $base = $self->{'name'};
     $base =~ s/::/-/g;
 
     return $RT::LocalPluginPath."/".$base;
-
 }
 
 =head2 ComponentRoot
 
-Returns the directory this plugin has installed its HTML::Mason templates into
+Returns the directory this plugin has installed its L<HTML::Mason> templates into
 
 =cut
 
-sub ComponentRoot {
-    my $self = shift;
-
-    return $self->_BasePath."/html";
-}
+sub ComponentRoot { return $_[0]->Path('html') }
 
 =head2 PoDir
 
@@ -110,10 +122,6 @@
 
 =cut
 
-sub PoDir {
-    my $self = shift;
-    return $self->_BasePath."/po";
-
-}
+sub PoDir { return $_[0]->Path('po') }
 
 1;

Modified: rt/3.8/branches/3.8.1-releng/sbin/rt-setup-database.in
==============================================================================
--- rt/3.8/branches/3.8.1-releng/sbin/rt-setup-database.in	(original)
+++ rt/3.8/branches/3.8.1-releng/sbin/rt-setup-database.in	Mon Aug 11 19:36:24 2008
@@ -233,7 +233,7 @@
     $RT::Handle->dbh( undef );
     RT::ConnectToDatabase();
     RT::InitLogging();
-    my ($status, $msg) = RT::Handle->CheckCompatibility( $RT::Handle->dbh, 'post' );
+    my ($status, $msg) = RT::Handle->CheckCompatibility( $RT::Handle->dbh, 'pre' );
     return ($status, $msg) unless $status;
 
     print "Now inserting RT core system objects\n";
@@ -244,7 +244,7 @@
     my %args = @_;
     $RT::Handle = new RT::Handle;
     RT::Init();
-    my ($status, $msg) = RT::Handle->CheckCompatibility( $RT::Handle->dbh, 'post' );
+    my ($status, $msg) = RT::Handle->CheckCompatibility( $RT::Handle->dbh, 'pre' );
     return ($status, $msg) unless $status;
 
     print "Now inserting data\n";
@@ -269,6 +269,7 @@
         }
         $upgrading_from = scalar <STDIN>;
         chomp $upgrading_from;
+        $upgrading_from =~ s/\s+//g;
     } while $upgrading_from !~ /^\d+\.\d+\.\d+$/;
 
     my $upgrading_to = $RT::VERSION;
@@ -278,22 +279,55 @@
     return (1, "The version $upgrading_to you're upgrading to is up to date")
         if RT::Handle::cmp_version( $upgrading_from, $upgrading_to ) == 0;
 
-    opendir my $dh, $base_dir or die "couldn't open dir: $!";
-    my @versions = grep -d "$base_dir/$_" && /\d+\.\d+\.\d+/, readdir $dh;
-    closedir $dh;
-
-    @versions =
-        grep RT::Handle::cmp_version($_, $upgrading_to) <= 0,
-        grep RT::Handle::cmp_version($_, $upgrading_from) > 0,
-        sort RT::Handle::cmp_version @versions;
+    my @versions = get_versions_from_to($base_dir, $upgrading_from, $upgrading_to);
 
     return (1, "No DB changes between $upgrading_from and $upgrading_to")
         unless @versions;
 
-    print "Going to apply following upgrades:\n";
+    print "\nGoing to apply following upgrades:\n";
     print map "* $_\n", @versions;
 
-    print "HI THERE IT'S VERY IMPORTANT TO BACK UP BEFORE THIS STEP\n\n";
+    {
+        my $custom_upgrading_to = undef;
+        do {
+            if ( defined $custom_upgrading_to ) {
+                print "Doesn't match #.#.#: ";
+            } else {
+                print "\nEnter RT version if you want to stop upgrade at some point,\n";
+                print "  or leave it blank if you want apply above upgrades: ";
+            }
+            $custom_upgrading_to = scalar <STDIN>;
+            chomp $custom_upgrading_to;
+            $custom_upgrading_to =~ s/\s+//g;
+            last unless $custom_upgrading_to;
+        } while $custom_upgrading_to !~ /^\d+\.\d+\.\d+$/;
+
+        if ( $custom_upgrading_to ) {
+            return (
+                0, "The version you entered ($custom_upgrading_to) is lower than\n"
+                ."version you're upgrading from ($upgrading_from)"
+            ) if RT::Handle::cmp_version( $upgrading_from, $custom_upgrading_to ) > 0;
+
+            return (1, "The version you're upgrading to is up to date")
+                if RT::Handle::cmp_version( $upgrading_from, $custom_upgrading_to ) == 0;
+
+            if ( RT::Handle::cmp_version( $RT::VERSION, $custom_upgrading_to ) < 0 ) {
+                print "Version you entered is greater than installed ($RT::VERSION).\n";
+                _yesno() or exit(-2);
+            }
+            # ok, checked everything no let's refresh list
+            $upgrading_to = $custom_upgrading_to;
+            @versions = get_versions_from_to($base_dir, $upgrading_from, $upgrading_to);
+
+            return (1, "No DB changes between $upgrading_from and $upgrading_to")
+                unless @versions;
+
+            print "\nGoing to apply following upgrades:\n";
+            print map "* $_\n", @versions;
+        }
+    }
+
+    print "\nHI THERE IT'S VERY IMPORTANT TO BACK UP BEFORE THIS STEP\n\n";
     _yesno() or exit(-2) unless $args{'force'};
 
     foreach my $v ( @versions ) {
@@ -312,6 +346,19 @@
     return 1;
 }
 
+sub get_versions_from_to {
+    my ($base_dir, $from, $to) = @_;
+
+    opendir my $dh, $base_dir or die "couldn't open dir: $!";
+    my @versions = grep -d "$base_dir/$_" && /\d+\.\d+\.\d+/, readdir $dh;
+    closedir $dh;
+
+    return
+        grep RT::Handle::cmp_version($_, $to) <= 0,
+        grep RT::Handle::cmp_version($_, $from) > 0,
+        sort RT::Handle::cmp_version @versions;
+}
+
 sub error {
     my ($action, $msg) = @_;
     print STDERR "Couldn't finish '$action' step.\n\n";


More information about the Rt-commit mailing list