From: <mp...@kr...> - 2008-05-22 18:03:53
|
Revision: 5154 Author: mpeters Date: 2008-05-22 13:03:52 -0400 (Thu, 22 May 2008) Log Message: ----------- adding no-db option to krang_upgrade so it can be used easier on setups with multiple machines, but with a shared db Modified Paths: -------------- branches/krang_v3_02/bin/krang_upgrade branches/krang_v3_02/lib/Krang/Upgrade.pm branches/krang_v3_02/upgrade/V3_00.pm branches/krang_v3_02/upgrade/V3_01.pm branches/krang_v3_02/upgrade/V3_02.pm Modified: branches/krang_v3_02/bin/krang_upgrade =================================================================== --- branches/krang_v3_02/bin/krang_upgrade 2008-05-22 16:35:54 UTC (rev 5153) +++ branches/krang_v3_02/bin/krang_upgrade 2008-05-22 17:03:52 UTC (rev 5154) @@ -117,6 +117,10 @@ data files and you know that nothing has changed the ownership of the files + --no-db - Skip any database related changes for the upgrade. This + is mainly used if you have multiple machines running Krang + but which share a common database. + --help - Show usage --man - Show full man page @@ -202,8 +206,8 @@ install_new_krang(); apply_upgrades(); update_version(); - update_db_version(); - clear_sessions(); + update_db_version() unless $options{'no-db'}; + clear_sessions() unless $options{'no-db'}; start_krang() unless $options{'no-start'}; output_report(); @@ -494,9 +498,10 @@ # Get package name by trimming off ".pm" my $package = $module; $package =~ s/\.pm$//; + my $no_db = $options{'no-db'} ? 1 : 0; my $upgrade_cmd = "KRANK_CONF_NOCHECK=1 KRANG_ROOT=$KrangRoot PERL5LIB=$perl5lib $PERL_BIN"; - $upgrade_cmd .= " -M$package -e 'my \$ug = $package->new(); \$ug->upgrade()'"; + $upgrade_cmd .= " -M$package -e 'my \$ug = $package->new(); \$ug->upgrade(no_db => $no_db)'"; system($upgrade_cmd) && die("Error using upgrade module '$module'"); } Modified: branches/krang_v3_02/lib/Krang/Upgrade.pm =================================================================== --- branches/krang_v3_02/lib/Krang/Upgrade.pm 2008-05-22 16:35:54 UTC (rev 5153) +++ branches/krang_v3_02/lib/Krang/Upgrade.pm 2008-05-22 17:03:52 UTC (rev 5154) @@ -82,10 +82,21 @@ an upgrade. This method calls C<per_installation()>, and then calls C<per_instance()> once for each installed instance. +The following named parameters may be passed which will then get passed +along to C<per_installation()> and C<per_instance()>. +=over + +=item * no_db + +This tells the upgrade module that the upgrade should not make changes to +the database. + =back +=back + =head1 SEE ALSO Releasing Krang: Creating Upgrade Modules F<docs/release.pod> @@ -115,10 +126,10 @@ sub upgrade { - my $self = shift; + my ($self, %args) = @_; # Run per_installation() method - $self->per_installation(); + $self->per_installation(%args); # Run per_instance() method, for each instance my @instances = pkg('Conf')->instances(); @@ -130,7 +141,7 @@ my $dbh = dbh(ignore_version=>1); # Call per_instance(), now that the environment has been established - $self->per_instance(); + $self->per_instance(%args); } } Modified: branches/krang_v3_02/upgrade/V3_00.pm =================================================================== --- branches/krang_v3_02/upgrade/V3_00.pm 2008-05-22 16:35:54 UTC (rev 5153) +++ branches/krang_v3_02/upgrade/V3_00.pm 2008-05-22 17:03:52 UTC (rev 5154) @@ -21,7 +21,8 @@ sub per_instance { - my $self = shift; + my ($self, %args) = @_; + return if $args{no_db}; my $dbh = dbh(); # add the 'use_autocomplete' preference Modified: branches/krang_v3_02/upgrade/V3_01.pm =================================================================== --- branches/krang_v3_02/upgrade/V3_01.pm 2008-05-22 16:35:54 UTC (rev 5153) +++ branches/krang_v3_02/upgrade/V3_01.pm 2008-05-22 17:03:52 UTC (rev 5154) @@ -12,7 +12,8 @@ } sub per_instance { - my $self = shift; + my ($self, %args) = @_; + return if $args{no_db}; my $dbh = dbh(); # correct size of binary DB columns Modified: branches/krang_v3_02/upgrade/V3_02.pm =================================================================== --- branches/krang_v3_02/upgrade/V3_02.pm 2008-05-22 16:35:54 UTC (rev 5153) +++ branches/krang_v3_02/upgrade/V3_02.pm 2008-05-22 17:03:52 UTC (rev 5154) @@ -11,7 +11,8 @@ } sub per_instance { - my $self = shift; + my ($self, %args) = @_; + return if $args{no_db}; my $dbh = dbh(); # add 'retired' and 'trashed' columns to STORY |