[Jifty-commit] jifty branch, master, updated. jifty-1.01209-3-gea6e6e2

Jifty commits jifty-commit at lists.jifty.org
Fri Dec 10 13:38:42 EST 2010


The branch, master has been updated
       via  ea6e6e2df8b1cdc18d6d8eadccdc8d257181352b (commit)
       via  94650ee30bf7363503271bdb43b962cba0c945bf (commit)
      from  787e19fe8c41227d1fb0fd1bb23fc97cf1efe374 (commit)

Summary of changes:
 lib/Jifty.pm               |    5 +++--
 lib/Jifty/Handle.pm        |   18 +++++++++++-------
 lib/Jifty/Script/Schema.pm |    7 ++++---
 3 files changed, 18 insertions(+), 12 deletions(-)

- Log -----------------------------------------------------------------
commit 94650ee30bf7363503271bdb43b962cba0c945bf
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Dec 10 13:35:16 2010 -0500

    Don't automatically upgrade the schema when running jifty schema --print
    
    This resolves [rt.cpan.org #20437].

diff --git a/lib/Jifty.pm b/lib/Jifty.pm
index b730c5a..3642c84 100644
--- a/lib/Jifty.pm
+++ b/lib/Jifty.pm
@@ -485,7 +485,8 @@ If C<no_handle> is set or our application's config file is missing a C<Database>
 
 sub setup_database_connection {
     my $self = shift;
-    my %args = (no_handle =>0,
+    my %args = (no_handle  => 0,
+                check_opts => {},
                 @_);
 
     # Don't setup the database connection if we're told not to
@@ -505,7 +506,7 @@ sub setup_database_connection {
             if $Jifty::DBI::Record::Memcached::MEMCACHED;
 
         # Make sure the app version matches the database version
-        Jifty->handle->check_schema_version()
+        Jifty->handle->check_schema_version(%{$args{'check_opts'}})
             unless $args{'no_version_check'};
     }
 }
diff --git a/lib/Jifty/Handle.pm b/lib/Jifty/Handle.pm
index 97109c7..1cfaa88 100644
--- a/lib/Jifty/Handle.pm
+++ b/lib/Jifty/Handle.pm
@@ -119,15 +119,20 @@ sub connect {
     }
 }
 
-=head2 check_schema_version
+=head2 check_schema_version [pretend => 0|1]
 
 Make sure that we have a recent enough database schema.  If we don't,
 then error out.
 
+If C<pretend => 1> is passed, then any auto-upgrade action this might take is
+dry-run only.
+
 =cut
 
 sub check_schema_version {
     my $self = shift;
+    my %opts = ( pretend => 0, @_ );
+
     require Jifty::Model::Metadata;
     my $autoup = delete Jifty->config->framework('Database')->{'AutoUpgrade'};
 
@@ -162,7 +167,7 @@ sub check_schema_version {
                 if ( $autoup ) {
                     warn
                         "Automatically upgrading your database to match the current application schema.\n";
-                    $self->_upgrade_schema();
+                    $self->_upgrade_schema('print' => $opts{pretend});
                 } else {
                     die
                         "Please run `bin/jifty schema --setup` to upgrade the database.\n";
@@ -187,7 +192,7 @@ sub check_schema_version {
             if ($autoup) {
                 warn
                     "Automatically upgrading your database to match the current Jifty schema\n";
-                $self->_upgrade_schema;
+                $self->_upgrade_schema('print' => $opts{pretend});
             } else {
                 die
                     "Please run `bin/jifty schema --setup` to upgrade the database.\n";
@@ -209,7 +214,7 @@ sub check_schema_version {
             if ($autoup) {
                 warn
                     "Automatically upgrading your database to match the current plugin schema\n";
-                $self->_upgrade_schema;
+                $self->_upgrade_schema('print' => $opts{pretend});
             } else {
                 die
                     "Please run `bin/jifty schema --setup` to upgrade the database.\n";
@@ -220,7 +225,7 @@ sub check_schema_version {
             if ($autoup) {
                 warn
                     "Automatically upgrading your database to match the current plugin schema\n";
-                $self->_upgrade_schema;
+                $self->_upgrade_schema('print' => $opts{pretend});
             } else {
                 die
                     "Please run `bin/jifty schema --setup` to upgrade the database.\n";
@@ -301,8 +306,7 @@ sub _create_original_database {
 
 sub _upgrade_schema {
     my $self = shift;
-
-    my $hack = {};
+    my $hack = { @_ };
     require Jifty::Script::Schema;
     bless $hack, "Jifty::Script::Schema";
     $hack->run_upgrades;
diff --git a/lib/Jifty/Script/Schema.pm b/lib/Jifty/Script/Schema.pm
index 8e6f8aa..141e4f3 100755
--- a/lib/Jifty/Script/Schema.pm
+++ b/lib/Jifty/Script/Schema.pm
@@ -214,6 +214,7 @@ sub probe_database_existence {
         Jifty->setup_database_connection(
             no_handle        => $no_handle,
             logger_component => 'SchemaTool',
+            check_opts       => { pretend => $self->{'print'} ? 1 : 0 }
         );
     };
     my $error = $@;

commit ea6e6e2df8b1cdc18d6d8eadccdc8d257181352b
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Dec 10 13:38:25 2010 -0500

    Add some newlines to our warnings to kill the line numbers

diff --git a/lib/Jifty/Script/Schema.pm b/lib/Jifty/Script/Schema.pm
index 141e4f3..6ee0791 100755
--- a/lib/Jifty/Script/Schema.pm
+++ b/lib/Jifty/Script/Schema.pm
@@ -439,7 +439,7 @@ sub upgrade_jifty_tables {
         $appv, "Jifty::Upgrade::Internal"
         );
     if ( $self->{print} ) {
-        warn "Need to upgrade jifty_db_version to $appv here!";
+        warn "Need to upgrade jifty_db_version to $appv here!\n";
     } else {
         Jifty::Model::Metadata->store( jifty_db_version => $appv );
     }
@@ -460,7 +460,7 @@ sub upgrade_application_tables {
 
     return unless $self->upgrade_tables( Jifty->app_class, $dbv, $appv );
     if ( $self->{print} ) {
-        warn "Need to upgrade application_db_version to $appv here!";
+        warn "Need to upgrade application_db_version to $appv here!\n";
     } else {
         Jifty::Model::Metadata->store( application_db_version => $appv );
     }
@@ -491,7 +491,7 @@ sub upgrade_plugin_tables {
                 $plugin->upgrade_class );
             if ( $self->{print} ) {
                 warn
-                    "Need to upgrade ${plugin_class}_db_version to $appv here!";
+                    "Need to upgrade ${plugin_class}_db_version to $appv here!\n";
             } else {
                 Jifty::Model::Metadata->store(
                     $plugin_class . '_db_version' => $appv );

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


More information about the Jifty-commit mailing list