[Rt-commit] rt branch, 4.2/deprecate-type-column-in-groups, created. rt-4.1.8-153-g90f272c

Ruslan Zakirov ruz at bestpractical.com
Tue May 21 09:31:09 EDT 2013


The branch, 4.2/deprecate-type-column-in-groups has been created
        at  90f272c308b0251fc9aa6900724439c4cd36afe2 (commit)

- Log -----------------------------------------------------------------
commit 723fca76ad3c1baab9b15910f63322c6289b5555
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri May 17 18:46:13 2013 +0400

    move backcompat files to code, for more flexibility

diff --git a/etc/upgrade/3.9.5/backcompat b/etc/upgrade/3.9.5/backcompat
index f7b66c9..ca0b289 100644
--- a/etc/upgrade/3.9.5/backcompat
+++ b/etc/upgrade/3.9.5/backcompat
@@ -1 +1,15 @@
-RT::ACE         LastUpdated LastUpdatedBy Creator Created
+my ($upgrade) = @_;
+
+my %removed;
+my @fields = qw/LastUpdated LastUpdatedBy Creator Created/;
+
+RT::ACE->_BuildTableAttributes;
+$RT::Logger->debug("Temporarily removing @fields from RT::ACE");
+$removed{$_} = delete $RT::Record::_TABLE_ATTR->{"RT::ACE"}{$_}
+    for @fields;
+
+$upgrade->();
+
+# Put back the fields we chopped off
+$RT::Record::_TABLE_ATTR->{"RT::ACE"}{$_} = $removed{$_}
+    for @fields;
diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index d9b7418..0b570b8 100644
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -268,30 +268,23 @@ sub action_insert {
     $file = $RT::EtcPath . "/initialdata" if $init && !$file;
     $file ||= $args{'datadir'}."/content";
 
-    # 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;
 
-    my @ret = $RT::Handle->InsertData( $file, $root_password );
+    my $upgrade = sub { @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}};
+    for my $file (@{$args{backcompat} || []}) {
+        my $lines = do {local $/; local @ARGV = ($file); <>};
+        my $sub = eval "sub {\n$lines\n}";
+        unless ($sub) {
+            warn "Failed to load backcompat $file: $@";
+            next;
+        }
+        my $current = $upgrade;
+        $upgrade = sub { $sub->($current) };
     }
 
+    $upgrade->();
+
     my $content;
     open my $handle, '<', $file or warn "Unable to open $file: $!";
     if ($handle) {

commit 90f272c308b0251fc9aa6900724439c4cd36afe2
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri May 17 18:49:13 2013 +0400

    we have to set Name = Type earlier for upgrade
    
    If we don't new code may fail during upgrade

diff --git a/etc/upgrade/4.1.10/backcompat b/etc/upgrade/4.1.10/backcompat
new file mode 100644
index 0000000..b4e69a3
--- /dev/null
+++ b/etc/upgrade/4.1.10/backcompat
@@ -0,0 +1,31 @@
+my $upgrade = shift;
+
+my $groups = RT::Groups->new( RT->SystemUser );
+$groups->Limit(
+    FIELD => 'Name', OPERATOR => '!=', VALUE => 'main.Type', QUOTEVALUE => 0
+);
+$groups->Limit(
+    FIELD => 'Domain',
+    VALUE => 'SystemInternal',
+    CASESENSITIVE => 0,
+);
+$groups->RowsPerPage(1);
+if ( $groups->Next ) {
+    my $dbh = $RT::Handle->dbh;
+    my $db_type = RT->Config->Get('DatabaseType');
+    if ( $db_type eq 'Oracle' || $db_type eq 'Pg' ) {
+        $dbh->do(
+            "UPDATE Groups SET Name = Type
+            WHERE LOWER(Domain) IN ('aclequivalence', 'systeminternal')
+                OR LOWER(Domain) LIKE '%-role'"
+        );
+    } else {
+        $dbh->do(
+            "UPDATE Groups SET Name = Type
+            WHERE Domain IN ('ACLEquivalence', 'SystemInternal')
+                OR Domain LIKE '%-Role'"
+        );
+    }
+}
+
+$upgrade->();

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


More information about the Rt-commit mailing list