MDL-21432 backup - make itemname bigger so it can store file component/area named
authorEloy Lafuente <stronk7@moodle.org>
Sat, 17 Jul 2010 11:23:52 +0000 (11:23 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Sat, 17 Jul 2010 11:23:52 +0000 (11:23 +0000)
lib/db/install.xml
lib/db/upgrade.php
version.php

index da79869..87bb9fa 100644 (file)
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="backupid"/>
         <FIELD NAME="backupid" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" COMMENT="unique id of the backup" PREVIOUS="id" NEXT="itemname"/>
-        <FIELD NAME="itemname" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" COMMENT="name of the component this id belongs to (usually table names)" PREVIOUS="backupid" NEXT="itemid"/>
+        <FIELD NAME="itemname" TYPE="char" LENGTH="160" NOTNULL="true" SEQUENCE="false" COMMENT="name of the component this id belongs to (usually table names)" PREVIOUS="backupid" NEXT="itemid"/>
         <FIELD NAME="itemid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="id of the component (usually table-&amp;gt;id values)" PREVIOUS="itemname" NEXT="newitemid"/>
         <FIELD NAME="newitemid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="new id of the component after restore" PREVIOUS="itemid" NEXT="parentitemid"/>
         <FIELD NAME="parentitemid" TYPE="int" LENGTH="10" NOTNULL="false" UNSIGNED="true" SEQUENCE="false" COMMENT="other id that can be useful to represent parent-child relations" PREVIOUS="newitemid" NEXT="info"/>
       </KEYS>
     </TABLE>
   </TABLES>
-</XMLDB>
\ No newline at end of file
+</XMLDB>
index 5f532e0..bafb19d 100644 (file)
@@ -4790,6 +4790,37 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
         upgrade_main_savepoint(true, 2010071300);
     }
 
+    if ($oldversion < 2010071700) { // Make itemname bigger (160cc) to store component+filearea
+
+        $table = new xmldb_table('backup_ids_template');
+        // Define key backupid_itemname_itemid_uk (unique) to be dropped form backup_ids_template
+        $key = new xmldb_key('backupid_itemname_itemid_uk', XMLDB_KEY_UNIQUE, array('backupid', 'itemname', 'itemid'));
+        // Define index backupid_parentitemid_ix (not unique) to be dropped form backup_ids_template
+        $index = new xmldb_index('backupid_parentitemid_ix', XMLDB_INDEX_NOTUNIQUE, array('backupid', 'itemname', 'parentitemid'));
+        // Define field itemname to be 160cc
+        $field = new xmldb_field('itemname', XMLDB_TYPE_CHAR, '160', null, XMLDB_NOTNULL, null, null, 'backupid');
+
+        // Launch drop key backupid_itemname_itemid_uk
+        $dbman->drop_key($table, $key);
+        // Conditionally launch drop index backupid_parentitemid_ix
+        if ($dbman->index_exists($table, $index)) {
+            $dbman->drop_index($table, $index);
+        }
+
+        // Changing precision of field itemname on table backup_ids_template to (160)
+        $dbman->change_field_precision($table, $field);
+
+        // Launch add key backupid_itemname_itemid_uk
+        $dbman->add_key($table, $key);
+        // Conditionally launch add index backupid_parentitemid_ix
+        if (!$dbman->index_exists($table, $index)) {
+            $dbman->add_index($table, $index);
+        }
+
+        // Main savepoint reached
+        upgrade_main_savepoint(true, 2010071700);
+    }
+
 
     return true;
 }
index 24c5fc3..a99ee5f 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-    $version = 2010071600;  // YYYYMMDD   = date of the last version bump
+    $version = 2010071700;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 Preview 4+ (Build: 20100717)';  // Human-friendly version name