[Rt-commit] rt branch, upgrade-history, created. rt-3.9.7-961-g8ecb63f
Shawn Moore
sartak at bestpractical.com
Mon Dec 20 15:46:29 EST 2010
The branch, upgrade-history has been created
at 8ecb63f529172081883ad330a6e20f55c10cc53b (commit)
- Log -----------------------------------------------------------------
commit 2fb13322b3bf854f23f780fa96576a7e83803639
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 52b534d..596cfd6 100755
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@ -257,6 +257,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 3b12bb00e2d13df279555879182d8f1504a92f3b
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 596cfd6..9d17ae6 100755
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@ -283,6 +283,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 d4a5323765c3bb39452881109cc86c9c69919247
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 9d17ae6..96a0b3d 100755
--- a/lib/RT/System.pm
+++ b/lib/RT/System.pm
@@ -270,7 +270,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 bebd3c51a01a67134ab5af373ff1951fb04c93f4
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 01687c8..fb00725 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -350,6 +350,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],
+ });
+
foreach my $v ( @versions ) {
print "Processing $v\n";
my %tmp = (%args, datadir => "$base_dir/$v", datafile => undef);
commit b5d8565bcc9762d85e8123a78e7e506404526aed
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 fb00725..65ad32f 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -358,6 +358,7 @@ sub action_upgrade {
versions => [@versions],
});
+ my $previous = $upgrading_from;
foreach my $v ( @versions ) {
print "Processing $v\n";
my %tmp = (%args, datadir => "$base_dir/$v", datafile => undef);
@@ -370,6 +371,15 @@ sub action_upgrade {
if ( -e "$base_dir/$v/content" ) {
action_insert( %tmp );
}
+
+ RT->System->AddUpgradeHistory(RT => {
+ action => 'upgrade',
+ type => 'individual upgrade',
+ from => $previous,
+ to => $v,
+ });
+
+ $previous = $v;
}
return 1;
}
commit bb6a02b7e099afbd2430e494cb8e68e62b9f9d8f
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 65ad32f..fc87bcc 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -266,7 +266,15 @@ sub action_insert {
$file = $RT::EtcPath . "/initialdata" if $init && !$file;
$file ||= $args{'datadir'}."/content";
- return $RT::Handle->InsertData( $file, $root_password );
+ ($status, $msg) = $RT::Handle->InsertData( $file, $root_password );
+ return ($status, $msg) unless $status;
+
+ RT->System->AddUpgradeHistory(RT => {
+ action => 'insert',
+ filename => $file,
+ });
+
+ return ($status, $msg);
}
sub action_upgrade {
commit ecea5dc22c07f450c3d7c906f8dbba790580c45b
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 fc87bcc..1904853 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -272,6 +272,7 @@ sub action_insert {
RT->System->AddUpgradeHistory(RT => {
action => 'insert',
filename => $file,
+ stage => 'after',
});
return ($status, $msg);
@@ -361,6 +362,7 @@ sub action_upgrade {
RT->System->AddUpgradeHistory(RT => {
type => 'full upgrade',
action => 'upgrade',
+ stage => 'before',
from => $upgrading_from,
to => $upgrading_to,
versions => [@versions],
@@ -383,6 +385,7 @@ sub action_upgrade {
RT->System->AddUpgradeHistory(RT => {
action => 'upgrade',
type => 'individual upgrade',
+ stage => 'after',
from => $previous,
to => $v,
});
commit 5a356dc04558b3a09b4239fc2e064b419d545f5b
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 1904853..949e379 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -371,6 +371,15 @@ sub action_upgrade {
my $previous = $upgrading_from;
foreach my $v ( @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);
if ( -e "$base_dir/$v/schema.$db_type" ) {
action_schema( %tmp );
@@ -392,6 +401,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 067b4379969df77581c8ba0e43eef956ffec349d
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 14e1fcf..5633b20 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -225,6 +225,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 e028ca9e78a73076bb66712a52df33fa990eabb2
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 5633b20..f3a72d5 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -236,6 +236,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;
@@ -253,6 +254,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 a07af6934c97e895e50dbca8997d67b14ebe69a8
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 949e379..66af7dc 100755
--- a/sbin/rt-setup-database.in
+++ b/sbin/rt-setup-database.in
@@ -359,6 +359,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 8ecb63f529172081883ad330a6e20f55c10cc53b
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 f3a72d5..80f4aac 100644
--- a/share/html/Admin/Tools/Configuration.html
+++ b/share/html/Admin/Tools/Configuration.html
@@ -246,7 +246,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} %>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list