[Jifty-commit] r4630 - in jifty/trunk: lib/Jifty lib/Jifty/Script
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Dec 6 14:06:57 EST 2007
Author: alexmv
Date: Thu Dec 6 14:06:56 2007
New Revision: 4630
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Handle.pm
jifty/trunk/lib/Jifty/Script/Schema.pm
Log:
r25493 at zoq-fot-pik: chmrr | 2007-12-06 14:06:31 -0500
* Check and upgrade plugin versions
Modified: jifty/trunk/lib/Jifty/Handle.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Handle.pm (original)
+++ jifty/trunk/lib/Jifty/Handle.pm Thu Dec 6 14:06:56 2007
@@ -206,6 +206,39 @@
}
}
+ # Plugin version check
+ for my $plugin ( Jifty->plugins ) {
+ my $plugin_class = ref $plugin;
+
+ my $dbv
+ = Jifty::Model::Metadata->load( $plugin_class . '_db_version' );
+ my $appv = version->new( $plugin->version );
+
+ if ( not defined $dbv ) {
+ warn
+ "$plugin_class plugin isn't installed in database\n";
+ if ($autoup) {
+ warn
+ "Automatically upgrading your database to match the current plugin schema\n";
+ $self->_upgrade_schema;
+ } else {
+ die
+ "Please run `bin/jifty schema --setup` to upgrade the database.\n";
+ }
+ } elsif (version->new($dbv) < $appv) {
+ warn
+ "$plugin_class plugin version in database ($dbv) doesn't match running plugin version ($appv)\n";
+ if ($autoup) {
+ warn
+ "Automatically upgrading your database to match the current plugin schema\n";
+ $self->_upgrade_schema;
+ } else {
+ die
+ "Please run `bin/jifty schema --setup` to upgrade the database.\n";
+ }
+ }
+ }
+
}
=head2 create_database MODE
Modified: jifty/trunk/lib/Jifty/Script/Schema.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Schema.pm (original)
+++ jifty/trunk/lib/Jifty/Script/Schema.pm Thu Dec 6 14:06:56 2007
@@ -137,26 +137,28 @@
logger_component => 'SchemaTool',
);
};
+ my $error = $@;
- if ( $@ =~ /doesn't match (application schema|running jifty) version/i ) {
+ if ( $error =~ /doesn't match (application schema|running jifty|running plugin) version/i
+ or $error =~ /plugin isn't installed in database/i ) {
# We found an out-of-date DB. Upgrade it
$self->{setup_tables} = 1;
- } elsif ( $@ =~ /no version in the database/i ) {
+ } elsif ( $error =~ /no version in the database/i ) {
# No version table. Assume the DB is empty.
$self->{create_all_tables} = 1;
- } elsif ( $@ =~ /database .*? does not exist/i
- or $@ =~ /unknown database/i )
+ } elsif ( $error =~ /database .*? does not exist/i
+ or $error =~ /unknown database/i )
{
# No database exists; we'll need to make one and fill it up
$self->{create_database} = 1;
$self->{create_all_tables} = 1;
- } elsif ($@) {
+ } elsif ($error) {
# Some other unexpected error; rethrow it
- die $@;
+ die $error;
}
# Setting up tables requires creating the DB if we just dropped it
More information about the Jifty-commit
mailing list