[Jifty-commit] r2849 - in jifty/trunk: lib/Jifty/Script

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Feb 26 20:13:20 EST 2007


Author: jesse
Date: Mon Feb 26 20:13:19 2007
New Revision: 2849

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Script/Schema.pm

Log:
 r48514 at pinglin:  jesse | 2007-02-25 15:20:15 -0500
 * Plugin templates should override the core, but not application templates
 r48515 at pinglin:  jesse | 2007-02-25 16:14:59 -0500
 * Since we use the schema tool to manage jifty's database, it's important that it be able to be called from running code (including a DESTROY block). As it was, we were initializing (reinitializing) Jifty from within the DESTROY. That doesn't work so well.
 
 r48516 at pinglin:  jesse | 2007-02-25 16:17:30 -0500
 * Better test for "jifty already initted"
 r48564 at pinglin:  jesse | 2007-02-26 20:07:19 -0500
 * Fix adding columns during an upgrade.


Modified: jifty/trunk/lib/Jifty/Script/Schema.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Schema.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/Schema.pm	Mon Feb 26 20:13:19 2007
@@ -375,7 +375,7 @@
                         my $renamed = $upgradeclass->just_renamed || {};
 
                         # skip it if this was dropped by a rename
-                        $model->drop_column_sql($col->name)
+                        _exec_sql($model->drop_column_sql($col->name))
                             unless defined $renamed
                                 ->{ $model->table }
                                 ->{'drop'}
@@ -384,12 +384,12 @@
                 }
 
                 # If they're new, add them
-                if ($model->can( 'since' ) and defined $col->since and $appv >= $col->since and $col->since >$dbv ) {
+                if ($col->can( 'since' ) and defined $col->since and $appv >= $col->since and $col->since >$dbv ) {
                     unshift @{ $UPGRADES{ $col->since } }, sub {
                         my $renamed = $upgradeclass->just_renamed || {};
 
                         # skip it if this was added by a rename
-                        $model->add_column_sql($col->name)
+                        _exec_sql($model->add_column_sql($col->name))
                             unless defined $renamed
                                 ->{ $model->table }
                                 ->{'add'}
@@ -427,9 +427,7 @@
                 $log->info("Running upgrade script");
                 $thing->();
             } else {
-                my $ret = Jifty->handle->simple_query($thing);
-                $ret
-                    or die "error updating a table: " . $ret->error_message;
+                _exec_sql($thing);
             }
         }
     }
@@ -547,6 +545,13 @@
     }
 }
 
+sub _exec_sql {
+    my $sql = shift;
+    my $ret = Jifty->handle->simple_query($sql);
+    $ret or die "error updating a table: " . $ret->error_message;
+}
+
+
 1;
 
 __DATA__


More information about the Jifty-commit mailing list