[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.7-957-gd70f8b3
Alex Vandiver
alexmv at bestpractical.com
Mon Dec 20 16:47:35 EST 2010
The branch, 3.9-trunk has been updated
via d70f8b30ab6b3114aaaeef3830d21c552ccfaace (commit)
from 9e76a3be9767805dcaa72234ad48ea8798839db7 (commit)
Summary of changes:
etc/upgrade/3.9.1/content | 9 ---------
etc/upgrade/3.9.5/backcompat | 1 +
etc/upgrade/3.9.7/content | 13 -------------
sbin/rt-setup-database.in | 31 ++++++++++++++++++++++++++++---
4 files changed, 29 insertions(+), 25 deletions(-)
create mode 100644 etc/upgrade/3.9.5/backcompat
- Log -----------------------------------------------------------------
commit d70f8b30ab6b3114aaaeef3830d21c552ccfaace
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Dec 20 15:18:23 2010 -0500
Allow ignoring of current columns when upgrading through old versions
RT 3.9.5 added three columns to the ACL table; if the user is
upgrading through any versions before that which attempt to add rows
to the ACL table (3.8.2, 3.9.1), they will fail. Work around this by
temporarily removing the columns from RT's internal schema if the an
upgrade predates the columns being added. To determine when key
columns were added, look for a file named 'backcompat' in the
appropriate upgrade directory.
diff --git a/etc/upgrade/3.9.1/content b/etc/upgrade/3.9.1/content
index bed3e74..c7bc535 100644
--- a/etc/upgrade/3.9.1/content
+++ b/etc/upgrade/3.9.1/content
@@ -1,15 +1,6 @@
@Initial = (
sub {
use strict;
- use RT::ACE;
- {
- package RT::ACE;
- my $throwaway = RT::ACE->new(RT->SystemUser);
- delete $TABLE_ATTR{'RT::ACE'}->{LastUpdated};
- delete $TABLE_ATTR{'RT::ACE'}->{LastUpdatedBy};
- }
-
-
$RT::Logger->debug('Make sure templates all have known types');
my $templates = RT::Templates->new(RT->SystemUser);
diff --git a/etc/upgrade/3.9.5/backcompat b/etc/upgrade/3.9.5/backcompat
new file mode 100644
index 0000000..611ab51
--- /dev/null
+++ b/etc/upgrade/3.9.5/backcompat
@@ -0,0 +1 @@
+RT::ACE LastUpdated LastUpdatedBy Creator Created
diff --git a/etc/upgrade/3.9.7/content b/etc/upgrade/3.9.7/content
index 7ca2744..9dfb114 100644
--- a/etc/upgrade/3.9.7/content
+++ b/etc/upgrade/3.9.7/content
@@ -20,19 +20,6 @@ my $move_attributes = sub {
@Initial = (
sub {
- use RT::ACE;
- {
- # if we're coming from 3.8, we've gone and disabled attributes
- # on the ACL table in 3.9.1 or so. Regenerating them is important
- package RT::ACE;
- my $throwaway = RT::ACE->new(RT->SystemUser);
- delete $TABLE_ATTR{'RT::ACE'};
- $throwaway = RT::ACE->new(RT->SystemUser);
- }
-
-
- },
- sub {
return $move_attributes->( 'Users', 'RT::User', 'AuthToken');
},
sub {
diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index 01687c8..c5ac3c4 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -266,7 +266,30 @@ sub action_insert {
$file = $RT::EtcPath . "/initialdata" if $init && !$file;
$file ||= $args{'datadir'}."/content";
- return $RT::Handle->InsertData( $file, $root_password );
+ # Slurp in backcompat
+ my %removed;
+ my @back = @{$args{backcompat} || []};
+ if (@back) {
+ my @lines = do {local @ARGV = @back; <>};
+ for (@lines) {
+ s/\#.*//;
+ next unless /\S/;
+ my ($class, @fields) = split;
+ $class->_BuildTableAttributes;
+ $RT::Logger->debug("Temporarily removing @fields from $class");
+ $removed{$class}{$_} = delete $RT::Record::_TABLE_ATTR->{$class}{$_}
+ for @fields;
+ }
+ }
+
+ my @ret = $RT::Handle->InsertData( $file, $root_password );
+
+ # Put back the fields we chopped off
+ for my $class (keys %removed) {
+ $RT::Record::_TABLE_ATTR->{$class}{$_} = $removed{$class}{$_}
+ for keys %{$removed{$class}};
+ }
+ return @ret;
}
sub action_upgrade {
@@ -350,9 +373,11 @@ sub action_upgrade {
print "\nIT'S VERY IMPORTANT TO BACK UP BEFORE THIS STEP\n\n";
_yesno() or exit(-2) unless $args{'force'};
- foreach my $v ( @versions ) {
+ foreach my $n ( 0..$#versions ) {
+ my $v = $versions[$n];
+ my @back = grep {-e $_} map {"$base_dir/$versions[$_]/backcompat"} $n+1..$#versions;
print "Processing $v\n";
- my %tmp = (%args, datadir => "$base_dir/$v", datafile => undef);
+ my %tmp = (%args, datadir => "$base_dir/$v", datafile => undef, backcompat => \@back);
if ( -e "$base_dir/$v/schema.$db_type" ) {
action_schema( %tmp );
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list