Author: sevein
Date: Tue Jul 10 19:38:19 2012
New Revision: 11895

Log:
Add try/catch to SQL upgrade task, cosmetic changes

Modified:
   trunk/lib/task/migrate/arUpgradeSqlTask.class.php

Modified: trunk/lib/task/migrate/arUpgradeSqlTask.class.php
==============================================================================
--- trunk/lib/task/migrate/arUpgradeSqlTask.class.php   Tue Jul 10 18:11:47 
2012        (r11894)
+++ trunk/lib/task/migrate/arUpgradeSqlTask.class.php   Tue Jul 10 19:38:19 
2012        (r11895)
@@ -69,7 +69,7 @@
     // Get initial version
     $sql = 'SELECT value AS version
       FROM setting JOIN setting_i18n ON setting.id = setting_i18n.id
-      WHERE name="version";';
+      WHERE name = "version";';
 
     $this->initialVersion = QubitPdo::fetchColumn($sql);
 
@@ -121,23 +121,31 @@
 
     // Find all the upgrade classes in lib/task/migrate
     $version = $this->initialVersion;
+
     foreach 
(sfFinder::type('file')->maxdepth(0)->name('arUpgrader*.class.php')->in(sfConfig::get('sf_lib_dir').'/task/migrate')
 as $filename)
     {
       $className = preg_replace('/.*(arUpgrader\d+).*/', '$1', $filename);
       $class = new $className;
 
-      if ($class::INIT_VERSION <= $version)
+      if ($class::INIT_VERSION > $version)
+      {
+        continue;
+      }
+
+      try
       {
         $this->logSection('upgrade-sql', sprintf('Upgrading from Release %s', 
$class::MILESTONE));
         while ($class->up($version, $this->configuration))
         {
-          $this->logSection('upgrade-sql', sprintf('Upgrading to %s', 
++$version));
-
           // Update version in database
           $sql = 'UPDATE setting_i18n SET value = ? WHERE id = (SELECT id FROM 
setting WHERE name = ?);';
-          QubitPdo::modify($sql, array($version, 'version'));
+          QubitPdo::modify($sql, array(++$version, 'version'));
         }
       }
+      catch (Exception $e)
+      {
+        throw new sfException('The task failed while trying to upgrade to 
v'.$version.'.');
+      }
     }
 
     if ($this->initialVersion == $version)

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to