[Rt-commit] rt branch, 4.2/upgrade-history, created. rt-4.0.5-294-gd27cf3b

Jim Brandt jbrandt at bestpractical.com
Wed Mar 21 16:27:20 EDT 2012


The branch, 4.2/upgrade-history has been created
        at  d27cf3bc8739d8faa5c89ef03d0deabc799b0857 (commit)

- Log -----------------------------------------------------------------
commit 23508c46ab702b60981f61eacd15cc404f22118e
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Dec 20 14:01:34 2010 -0500

    RT->System->AddUpgradeHistory('RT', {...})
    
        .. or RT->System->AddUpgradeHistory('RT::Extension::ExternalAuth', {...})

diff --git a/lib/RT/System.pm b/lib/RT/System.pm
index ad4a2c1..435c9db 100644
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@ -258,6 +258,32 @@ sub QueueCacheNeedsUpdate {
     }
 }
 
+=head2 AddUpgradeHistory realm, data
+
+Adds an entry to the upgrade history database. The realm can be either C<RT>
+for core RT upgrades, or the fully qualified name of a plugin. The data must be
+a hash reference.
+
+=cut
+
+sub AddUpgradeHistory {
+    my $self  = shift;
+    my $realm = shift;
+    my $data  = shift;
+
+    $data->{timestamp} ||= time;
+
+    my $upgrade_history_attr = $self->FirstAttribute('UpgradeHistory');
+    my $upgrade_history = $upgrade_history_attr ? $upgrade_history_attr->Content : {};
+
+    push @{ $upgrade_history->{$realm} }, $data;
+
+    $self->SetAttribute(
+        Name    => 'UpgradeHistory',
+        Content => $upgrade_history,
+    );
+}
+
 RT::Base->_ImportOverlays();
 
 1;

commit e42db7140b4fa59e4b80fd966cf5a0b015033db7
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Dec 20 14:08:17 2010 -0500

    UpgradeHistory for reading upgrade history

diff --git a/lib/RT/System.pm b/lib/RT/System.pm
index 435c9db..895e523 100644
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@ -284,6 +284,28 @@ sub AddUpgradeHistory {
     );
 }
 
+=head2 UpgradeHistory [realm]
+
+Returns the entries of RT's upgrade history. If a realm is specified, the list
+of upgrades for that realm will be returned. Otherwise a hash reference of
+C<< realm => [upgrades] >> will be returned.
+
+=cut
+
+sub UpgradeHistory {
+    my $self  = shift;
+    my $realm = shift;
+
+    my $upgrade_history_attr = $self->FirstAttribute('UpgradeHistory');
+    my $upgrade_history = $upgrade_history_attr ? $upgrade_history_attr->Content : {};
+
+    if ($realm) {
+        return @{ $upgrade_history->{$realm} || [] };
+    }
+
+    return $upgrade_history;
+}
+
 RT::Base->_ImportOverlays();
 
 1;

commit 19ac425fec02ce952bf4d4aacf031827f2f5c44d
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Dec 20 14:20:01 2010 -0500

    Always include the rt_version we're using to upgrade

diff --git a/lib/RT/System.pm b/lib/RT/System.pm
index 895e523..f2ff57e 100644
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@ -271,7 +271,8 @@ sub AddUpgradeHistory {
     my $realm = shift;
     my $data  = shift;
 
-    $data->{timestamp} ||= time;
+    $data->{timestamp}  ||= time;
+    $data->{rt_version} ||= $RT::VERSION;
 
     my $upgrade_history_attr = $self->FirstAttribute('UpgradeHistory');
     my $upgrade_history = $upgrade_history_attr ? $upgrade_history_attr->Content : {};

commit df361d8c3af94b6ae2f02072ebcc1d88187f7fd0
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Dec 20 14:26:00 2010 -0500

    First cut of adding history during an upgrade

diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index f31e896..cf80e89 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -373,6 +373,14 @@ sub action_upgrade {
     print "\nIT'S VERY IMPORTANT TO BACK UP BEFORE THIS STEP\n\n";
     _yesno() or exit(-2) unless $args{'force'};
 
+    RT->System->AddUpgradeHistory(RT => {
+        type      => 'full upgrade',
+        action    => 'upgrade',
+        from      => $upgrading_from,
+        to        => $upgrading_to,
+        versions  => [@versions],
+    });
+
     my ( $ret, $msg );
     foreach my $n ( 0..$#versions ) {
         my $v = $versions[$n];

commit 9f38ac8a1ab9a627817bfcf57e53db276b8015d6
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Dec 20 14:28:45 2010 -0500

    Add upgrade notes for each intermediate point upgrade too

diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index cf80e89..ff6277a 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -381,6 +381,7 @@ sub action_upgrade {
         versions  => [@versions],
     });
 
+    my $previous = $upgrading_from;
     my ( $ret, $msg );
     foreach my $n ( 0..$#versions ) {
         my $v = $versions[$n];
@@ -399,6 +400,15 @@ sub action_upgrade {
             ( $ret, $msg ) = action_insert( %tmp );
             return ( $ret, $msg ) unless $ret;
         }
+
+        RT->System->AddUpgradeHistory(RT => {
+            action => 'upgrade',
+            type   => 'individual upgrade',
+            from   => $previous,
+            to     => $v,
+        });
+
+        $previous = $v;
     }
     return 1;
 }

commit d16fb89e9fef148a70d5b00b368221dc24d434bd
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Dec 20 14:33:00 2010 -0500

    upgrade history for inserting initialdata

diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index ff6277a..a681e7b 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -289,6 +289,12 @@ sub action_insert {
         $RT::Record::_TABLE_ATTR->{$class}{$_} = $removed{$class}{$_}
             for keys %{$removed{$class}};
     }
+
+    RT->System->AddUpgradeHistory(RT => {
+        action   => 'insert',
+        filename => $file,
+    });
+
     return @ret;
 }
 

commit a07ae74610b5e7c9acd87831bf1cb462df754268
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Dec 20 14:36:34 2010 -0500

    Add before/after information for each upgrade history entry

diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index a681e7b..19f0d49 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -293,6 +293,7 @@ sub action_insert {
     RT->System->AddUpgradeHistory(RT => {
         action   => 'insert',
         filename => $file,
+        stage    => 'after',
     });
 
     return @ret;
@@ -382,6 +383,7 @@ sub action_upgrade {
     RT->System->AddUpgradeHistory(RT => {
         type      => 'full upgrade',
         action    => 'upgrade',
+        stage     => 'before',
         from      => $upgrading_from,
         to        => $upgrading_to,
         versions  => [@versions],
@@ -410,6 +412,7 @@ sub action_upgrade {
         RT->System->AddUpgradeHistory(RT => {
             action => 'upgrade',
             type   => 'individual upgrade',
+            stage  => 'after',
             from   => $previous,
             to     => $v,
         });

commit ed74b0f5f4636dee292880c61a607579a9139478
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Dec 20 14:36:45 2010 -0500

    Include before history for point upgrades, after history for the full upgrade

diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index 19f0d49..aa578ac 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -395,7 +395,17 @@ sub action_upgrade {
         my $v = $versions[$n];
         my @back = grep {-e $_} map {"$base_dir/$versions[$_]/backcompat"} $n+1..$#versions;
         print "Processing $v\n";
+
+        RT->System->AddUpgradeHistory(RT => {
+            action => 'upgrade',
+            type   => 'individual upgrade',
+            stage  => 'before',
+            from   => $previous,
+            to     => $v,
+        });
+
         my %tmp = (%args, datadir => "$base_dir/$v", datafile => undef, backcompat => \@back);
+
         if ( -e "$base_dir/$v/schema.$db_type" ) {
             ( $ret, $msg ) = action_schema( %tmp );
             return ( $ret, $msg ) unless $ret;
@@ -419,6 +429,16 @@ sub action_upgrade {
 
         $previous = $v;
     }
+
+    RT->System->AddUpgradeHistory(RT => {
+        type      => 'full upgrade',
+        action    => 'upgrade',
+        stage     => 'after',
+        from      => $upgrading_from,
+        to        => $upgrading_to,
+        versions  => [@versions],
+    });
+
     return 1;
 }
 

commit 28c431c3d08c403b8842b82440d7466d72600d75
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Dec 20 15:17:50 2010 -0500

    Begin displaying RT upgrade history in sys config

diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html
index ed7d465..37608d4 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -249,6 +249,40 @@ if ($item =~ /^\s*(.*?)\s*v(\S+);/) {
 </table>
 </&>
 
+<&|/Widgets/TitleBox, title => loc("RT upgrade history")&>
+
+% my $upgrade_history = RT->System->UpgradeHistory;
+% my @realms = ('RT', sort grep { $_ ne 'RT' } keys %$upgrade_history);
+% for my $realm (@realms) {
+<h4><% $realm %></h4>
+<table border="0" cellspacing="0" cellpadding="5" width="100%" class="collection">
+<tr class="collection-as-table">
+<th class="collection-as-table"><&|/l&>Action</&></th>
+<th class="collection-as-table"><&|/l&>Using RT Version</&></th>
+<th class="collection-as-table"><&|/l&>Time</&></th>
+
+<%perl>
+    my $i = 0;
+    for my $upgrade (@{ $upgrade_history->{$realm} }) {
+        # only list completed upgrades
+        next unless $upgrade->{stage} eq 'after';
+</%perl>
+<tr class="<% $i++ %2 ? 'oddline' : 'evenline'%>">
+    <td class="collection-as-table">
+        <% $upgrade->{action} %>
+    </td>
+    <td class="collection-as-table">
+        <% $upgrade->{rt_version} %>
+    </td>
+    <td class="collection-as-table">
+        <% scalar gmtime($upgrade->{timestamp}) %>
+    </td>
+</tr>
+% }
+</table>
+% }
+</&>
+
 <&|/Widgets/TitleBox, title => loc("Perl configuration") &>
 % require Config;
 <pre>

commit b4be9934f042c35f325cd71733e9ce2c6589efb1
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Dec 20 15:27:33 2010 -0500

    Add an extra column, and for upgrade display the versions

diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html
index 37608d4..b195ae7 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -260,6 +260,7 @@ if ($item =~ /^\s*(.*?)\s*v(\S+);/) {
 <th class="collection-as-table"><&|/l&>Action</&></th>
 <th class="collection-as-table"><&|/l&>Using RT Version</&></th>
 <th class="collection-as-table"><&|/l&>Time</&></th>
+<th class="collection-as-table"><&|/l&>Extra</&></th>
 
 <%perl>
     my $i = 0;
@@ -277,6 +278,11 @@ if ($item =~ /^\s*(.*?)\s*v(\S+);/) {
     <td class="collection-as-table">
         <% scalar gmtime($upgrade->{timestamp}) %>
     </td>
+    <td class="collection-as-table">
+% if ($upgrade->{action} eq 'upgrade') {
+    <&|/l, $upgrade->{from}, $upgrade->{to} &>from [_1] to [_2]</&>
+% }
+    </td>
 </tr>
 % }
 </table>

commit f36f77277b27b9be5ffe54508dc1879b6102def4
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Dec 20 15:38:02 2010 -0500

    Need to initialize RT->System before adding upgrade history

diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index aa578ac..fd464c9 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -380,6 +380,10 @@ sub action_upgrade {
     print "\nIT'S VERY IMPORTANT TO BACK UP BEFORE THIS STEP\n\n";
     _yesno() or exit(-2) unless $args{'force'};
 
+    RT->ConnectToDatabase();
+    RT->InitLogging();
+    RT->InitSystemObjects();
+
     RT->System->AddUpgradeHistory(RT => {
         type      => 'full upgrade',
         action    => 'upgrade',

commit 6b903f2879d2a79ba5f85d76113bfcc686a8396f
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Mon Dec 20 15:41:09 2010 -0500

    Be more specific for upgrades
    
        Otherwise it looks like you upgrade from 3.9.x to 3.9.y twice at the
        same time when y = x + 1

diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html
index b195ae7..94c9adf 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -270,7 +270,11 @@ if ($item =~ /^\s*(.*?)\s*v(\S+);/) {
 </%perl>
 <tr class="<% $i++ %2 ? 'oddline' : 'evenline'%>">
     <td class="collection-as-table">
-        <% $upgrade->{action} %>
+% if ($upgrade->{action} eq 'upgrade') { # type is more specific for upgrades
+    <% $upgrade->{type} %>
+% } else {
+    <% $upgrade->{action} %>
+% }
     </td>
     <td class="collection-as-table">
         <% $upgrade->{rt_version} %>

commit d27cf3bc8739d8faa5c89ef03d0deabc799b0857
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Dec 21 20:47:06 2010 -0500

    Include the content of the file we use for the insert action

diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in
index fd464c9..bb4e6b4 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -290,9 +290,17 @@ sub action_insert {
             for keys %{$removed{$class}};
     }
 
+    my $content;
+    open my $handle, '<', $file or warn "Unable to open $file: $!";
+    if ($handle) {
+        local $/; # slurp
+        $content = <$handle>;
+    }
+
     RT->System->AddUpgradeHistory(RT => {
         action   => 'insert',
         filename => $file,
+        content  => $content,
         stage    => 'after',
     });
 

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


More information about the Rt-commit mailing list