Author: sevein
Date: Thu Jul 12 17:10:42 2012
New Revision: 11917

Log:
Add logic to arUpgrade110 to keep the SQL schema synced, some fixes. Still 
needs more work.

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

Modified: trunk/lib/task/migrate/arUpgrader110.class.php
==============================================================================
--- trunk/lib/task/migrate/arUpgrader110.class.php      Thu Jul 12 16:46:59 
2012        (r11916)
+++ trunk/lib/task/migrate/arUpgrader110.class.php      Thu Jul 12 17:10:42 
2012        (r11917)
@@ -68,9 +68,9 @@
         $node->name = 'addAccessionRecord';
         $node->path = 'accession/add';
         $node->sourceCulture = 'en';
+        $node->label = 'Accession records';
 
         foreach (array(
-          'en' => 'Accession records',
           'es' => 'Registros de adhesiones',
           'fr' => 'Registre des entrées',
           'pl' => 'Nabytki',
@@ -98,9 +98,9 @@
         $node->name = 'manage';
         $node->path = 'accession/browse';
         $node->sourceCulture = 'en';
+        $node->label = 'Manage';
 
         foreach (array(
-          'en' => 'Manage',
           'es' => 'Administrar',
           'fr' => 'Gérer',
           'pl' => 'Zarządzanie',
@@ -113,7 +113,7 @@
           $node->menuI18ns[] = $nodeI18n;
         }
 
-        $node->save();
+        QubitMigrate::addMenu($node, $configuration);
 
         // Introduce it before "taxonomies"
         if (null !== $target = QubitMenu::getByName('taxonomies'))
@@ -127,9 +127,9 @@
         $node->name = 'accessions';
         $node->path = 'accession/browse';
         $node->sourceCulture = 'en';
+        $node->label = 'Accession records';
 
         foreach (array(
-          'en' => 'Accession records',
           'es' => 'Registros de adhesiones',
           'fr' => 'Registre des entrées',
           'pl' => 'Nabytki',
@@ -156,9 +156,9 @@
         $node->name = 'donors';
         $node->path = 'donor/browse';
         $node->sourceCulture = 'en';
+        $node->label = 'Donors';
 
         foreach (array(
-          'en' => 'Donors',
           'es' => 'Donantes',
           'fr' => 'Donateurs',
           'nl' => 'Schenkers',
@@ -186,9 +186,9 @@
         $node->name = 'rightsholders';
         $node->path = 'rightsholder/browse';
         $node->sourceCulture = 'en';
+        $node->value = 'Rights holders';
 
         foreach (array(
-          'en' => 'Rights holders',
           'es' => 'Titulares de derechos',
           'fr' => 'Détenteurs de droits',
           'nl' => 'Houders van rechten',
@@ -456,55 +456,25 @@
 
       // Migrate relation notes for date and description to relation_i18n table
       case 63:
-        break;
-
-        foreach (QubitNote::getAll() as $item)
-        {
-          if (!isset($item->typeId) && !isset($item->content))
-          {
-            continue;
-          }
 
-          switch ($item->typeId)
-          {
-            case QubitTerm::RELATION_NOTE_DATE_ID:
-              $colname = 'date';
-
-              break;
-
-            case QubitTerm::RELATION_NOTE_DESCRIPTION_ID:
-              $colname = 'description';
-
-              break;
-
-            default:
-              continue 2;
-          }
-
-          $criteria = new Criteria;
-          $criteria->add(QubitRelation::OBJECT_ID, $item->objectId);
-
-          // Replace relation note with relation_i18n row
-          // TODO
-          /*
-          if (isset($this->data['QubitRelation'][$item['object_id']]) && 
isset($item['content']))
-          {
-            $this->data['QubitRelation'][$item['object_id']]['source_culture'] 
= $item['source_culture'];
-            $this->data['QubitRelation'][$item['object_id']][$colname] = 
$item['content'];
-          }
-          */
-
-          $note->delete();
-        }
+        echo "63 ------------- TODO\n";
 
         break;
 
-      // Prior to revision 9340 all checksums were md5 and the algorithm was 
not
+      // Prior to r9340 all checksums were md5 and the algorithm was not
       // recorded, update checksum_type column
       case 64:
+
+        // Drop column checksum_type_id
+        QubitMigrate::dropColumn(QubitDigitalObject::TABLE_NAME, 
'checksum_type_id');
+
+        // Add column checksumn_type
+        QubitPdo::modify('ALTER TABLE digital_object ADD `checksum_type` 
VARCHAR(255) NOT NULL BEFORE `parent_id`');
+
+        // Set value md5 in some cases
         $sql  = 'UPDATE '.QubitDigitalObject::TABLE_NAME;
-        $sql += ' SET '.QubitDigitalObject::CHECKSUM_TYPE.' = "md5"';
-        $sql += ' WHERE CHAR_LENGTH('.QubitDigitalObject::CHECKSUM_TYPE.') > 
0';
+        $sql .= ' SET '.QubitDigitalObject::CHECKSUM_TYPE.' = "md5"';
+        $sql .= ' WHERE CHAR_LENGTH(checksum_type) > 0';
         QubitPdo::modify($sql);
 
         break;
@@ -516,10 +486,7 @@
         $node->name = 'importCsv';
         $node->path = 'object/importSelect?type=csv';
         $node->sourceCulture = 'en';
-        $nodeI18n = new QubitMenuI18n;
-        $nodeI18n->culture = 'en';
-        $nodeI18n->label= 'CSV';
-        $node->menuI18ns[] = $nodeI18n;
+        $node->label= 'CSV';
         $node->save();
 
         break;
@@ -531,10 +498,7 @@
         $node->name = 'globalReplace';
         $node->path = 'search/globalReplace';
         $node->sourceCulture = 'en';
-        $nodeI18n = new QubitMenuI18n;
-        $nodeI18n->culture = 'en';
-        $nodeI18n->label = 'Global search/replace';
-        $node->menuI18ns[] = $nodeI18n;
+        $node->label = 'Global search/replace';
         $node->save();
 
         break;
@@ -573,9 +537,9 @@
         $node->name = 'themes';
         $node->path = 'sfPluginAdminPlugin/themes';
         $node->sourceCulture = 'en';
+        $node->label = 'Themes';
 
         foreach (array(
-          'en' => 'Themes',
           'es' => 'Temas',
           'fr' => 'Thèmes',
           'nl' => 'Thema\'s',
@@ -704,9 +668,9 @@
         $node->name = 'browsePhysicalObjects';
         $node->path = 'physicalobject/browse';
         $node->sourceCulture = 'en';
+        $node->label = 'Physical storage';
 
         foreach (array(
-          'en' => 'Physical storage',
           'es' => 'Almacenamiento físico',
           'fr' => 'Localisation physique',
           'nl' => 'Bergplaats',
@@ -782,6 +746,33 @@
       // Return false if no upgrade available
       default:
 
+        // Drop unneeded tables
+        foreach array(
+          'historical_event',
+          'map',
+          'map_i18n',
+          'place',
+          'place_i18n',
+          'place_map_relation',
+          'system_event_table') as $item)
+        {
+          QubitMigrate::dropTable($item);
+        }
+
+        // Drop updated_at and created_at columns
+        foreach array(
+          'menu',
+          'note',
+          'other_name',
+          'property',
+          'status'
+          'taxonomy'
+          ) as $item)
+        {
+          QubitMigrate::dropColumn($item, 'updated_at');
+          QubitMigrate::dropColumn($item, 'created_at');
+        }
+
         return false;
     }
 

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