Author: jablko
Date: Mon Nov 23 10:36:34 2009
New Revision: 3943

Log:
First crack at making migrations finer grained, 
http://qubit-toolkit.org/wiki/index.php?title=Migrations#Fine_grained

Modified:
   trunk/data/fixtures/settings.yml
   trunk/lib/task/migrate/MigrateTask.class.php
   trunk/lib/task/migrate/QubitMigrate108to110.class.php

Modified: trunk/data/fixtures/settings.yml
==============================================================================
--- trunk/data/fixtures/settings.yml    Mon Nov 23 00:12:35 2009        (r3942)
+++ trunk/data/fixtures/settings.yml    Mon Nov 23 10:36:34 2009        (r3943)
@@ -1,9 +1,9 @@
 QubitSetting:
-  QubitSetting_1:
+  version:
     name: version
     editable: 0
     deleteable: 0
-    value: 'Qubit 1.1'
+    value: 3
   QubitSetting_2:
     name: upload_dir
     editable: 0

Modified: trunk/lib/task/migrate/MigrateTask.class.php
==============================================================================
--- trunk/lib/task/migrate/MigrateTask.class.php        Mon Nov 23 00:12:35 
2009        (r3942)
+++ trunk/lib/task/migrate/MigrateTask.class.php        Mon Nov 23 10:36:34 
2009        (r3943)
@@ -100,6 +100,11 @@
     // Incrementally call the upgrade task for each intervening version from
     // initial version to the target version
     $initialIndex = array_search($this->initialVersion, $this->validVersions);
+    if (false === $initialIndex)
+    {
+      $initialIndex = count($this->validVersions) - 2;
+    }
+
     $finalIndex = array_search($this->targetVersion, $this->validVersions);
 
     if ($initialIndex !== false && $finalIndex !== false && $initialIndex < 
$finalIndex)

Modified: trunk/lib/task/migrate/QubitMigrate108to110.class.php
==============================================================================
--- trunk/lib/task/migrate/QubitMigrate108to110.class.php       Mon Nov 23 
00:12:35 2009        (r3942)
+++ trunk/lib/task/migrate/QubitMigrate108to110.class.php       Mon Nov 23 
10:36:34 2009        (r3943)
@@ -34,17 +34,36 @@
    */
   protected function alterData()
   {
+    // Find version
+    foreach ($this->data['QubitSetting'] as $key => $value)
+    {
+      if ('version' == $value['name'])
+      {
+        $version = $value['value'][$value['source_culture']];
+        break;
+      }
+    }
+
+    switch ($version)
+    {
+      default:
+        $this->alterQubitStaticPages();
+
+      case 1:
+        $this->addIsdfFunctionTypes();
+
+      case 2:
+        $this->moveActorNameToOtherName();
+    }
+
     // Delete "stub" objects
     $this->deleteStubObjects();
 
-    $this->moveActorNameToOtherName();
+    $parser = new sfYamlParser;
+    $data = 
$parser->parse(file_get_contents(sfConfig::get('sf_data_dir').'/fixtures/settings.yml'));
 
-    // Add taxonomies and terms
-    $this->addIsdfFunctionTypes();
-
-    // Alter table data
-    $this->alterQubitSettings();
-    $this->alterQubitStaticPages();
+    // Update version
+    $this->data['QubitSetting'][$key] = $data['QubitSetting']['version'];
 
     return $this;
   }
@@ -150,25 +169,6 @@
   }
 
   /**
-   * Alter QubitSetting data
-   *
-   * @return QubitMigrate108to110 this object
-   */
-  protected function alterQubitSettings()
-  {
-    // Update version number
-    if ($settingVersionKey = $this->getRowKey('QubitSetting', 'name', 
'version'))
-    {
-      foreach ($this->data['QubitSetting'][$settingVersionKey]['value'] as 
$culture => $value)
-      {
-        $this->data['QubitSetting'][$settingVersionKey]['value'][$culture] = 
preg_replace('/1\.0\.8(\.1)?/', '1.1.0', $value);
-      }
-    }
-
-    return $this;
-  }
-
-  /**
    * Alter QubitStaticPage data
    *
    * @return QubitMigrate108to110 this object

--

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=.


Reply via email to