diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 2a264b901..43d03d91b 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -1,3 +1,9 @@ +6.1.0 + - Changed the output of upgrade.pl for better understanding. + - Added a --history option to upgrade.pl that displays the upgrade history + for each site. + + 6.0.3 - Fixed a recursive style change bug. - Bugfix [ 953593 ] perl -MWebGUI -e "" fails diff --git a/sbin/upgrade.pl b/sbin/upgrade.pl index d1fb72755..6259d30b9 100644 --- a/sbin/upgrade.pl +++ b/sbin/upgrade.pl @@ -24,6 +24,7 @@ use strict; use WebGUI::SQL; my $help; +my $history; my $override; my $quiet; my $mysql = "/usr/bin/mysql"; @@ -34,6 +35,7 @@ my $doit; GetOptions( 'help'=>\$help, + 'history'=>\$history, 'override'=>\$override, 'quiet'=>\$quiet, 'mysql=s'=>\$mysql, @@ -57,6 +59,10 @@ Options: --help Display this help message and exit. + --history Displays the upgrade history for each of + your sites. Note that running with this + flag will NOT run the upgrade. + --mysql The path to your mysql client executable. Defaults to '/usr/bin/mysql'. @@ -86,10 +92,14 @@ unless ($doit) { +--------------------------------------------------------------------+ | | -| W A R N I N G | +| For more information about this utility type: | +| | +| perl upgrade.pl --help | | | +--------------------------------------------------------------------+ | | +| W A R N I N G | +| | | There are no guarantees of any kind provided with this software. | | This utility has been tested rigorously, and has performed without | | error or consequence in our labs, and on our production servers | @@ -102,14 +112,9 @@ unless ($doit) { | | +--------------------------------------------------------------------+ | | -| For more information about this utility type: | -| | -| perl upgrade.pl --help | -| | -+--------------------------------------------------------------------+ -| | | You must include the command line argument "--doit" in your | -| command in order to bypass this message. | +| command in order to bypass this message. The upgrade will not run | +| without the "--doit" flag. | | | +--------------------------------------------------------------------+ @@ -138,28 +143,6 @@ our $configsPath = $webguiRoot.$slash."etc".$slash; our (%upgrade, %config); -## Find upgrade files. - -print "\nLooking for upgrade files...\n" unless ($quiet); -opendir(DIR,$upgradesPath) or die "Couldn't open $upgradesPath\n"; -my @files = readdir(DIR); -closedir(DIR); -foreach my $file (@files) { - if ($file =~ /upgrade_(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.(\w+)/) { - if (checkVersion($1)) { - if ($3 eq "sql") { - print "\tFound upgrade script from $1 to $2.\n" unless ($quiet); - $upgrade{$1}{sql} = $file; - } elsif ($3 eq "pl") { - print "\tFound upgrade executable from $1 to $2.\n" unless ($quiet); - $upgrade{$1}{pl} = $file; - } - $upgrade{$1}{from} = $1; - $upgrade{$1}{to} = $2; - } - } -} - ## Find site configs. print "\nGetting site configs...\n" unless ($quiet); @@ -195,7 +178,46 @@ foreach my $file (@files) { } } +if ($history) { + print "\nDisplaying upgrade history for each site.\n"; + require WebGUI::DateTime; + foreach my $file (keys %config) { + print "\n".$file."\n"; + my $dbh = DBI->connect($config{$file}{dsn},$config{$file}{dbuser},$config{$file}{dbpass}); + my $sth = WebGUI::SQL->read("select * from webguiVersion order by dateApplied asc, webguiVersion asc",$dbh); + while (my $data = $sth->hashRef) { + print "\t".sprintf("%-8s %-15s %-15s", + $data->{webguiVersion}, + WebGUI::DateTime::epochToHuman($data->{dateApplied},"%y-%m-%d"), + $data->{versionType})."\n"; + } + $sth->finish; + $dbh->disconnect; + } + exit; +} +## Find upgrade files. + +print "\nLooking for upgrade files...\n" unless ($quiet); +opendir(DIR,$upgradesPath) or die "Couldn't open $upgradesPath\n"; +my @files = readdir(DIR); +closedir(DIR); +foreach my $file (@files) { + if ($file =~ /upgrade_(\d+\.\d+\.\d+)-(\d+\.\d+\.\d+)\.(\w+)/) { + if (checkVersion($1)) { + if ($3 eq "sql") { + print "\tFound upgrade script from $1 to $2.\n" unless ($quiet); + $upgrade{$1}{sql} = $file; + } elsif ($3 eq "pl") { + print "\tFound upgrade executable from $1 to $2.\n" unless ($quiet); + $upgrade{$1}{pl} = $file; + } + $upgrade{$1}{from} = $1; + $upgrade{$1}{to} = $2; + } + } +} print "\nREADY TO BEGIN UPGRADES\n" unless ($quiet);