MDL-22145 backup - allowing longer backup types in DB
authorEloy Lafuente <stronk7@moodle.org>
Wed, 28 Apr 2010 21:42:50 +0000 (21:42 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Wed, 28 Apr 2010 21:42:50 +0000 (21:42 +0000)
lib/db/install.xml
lib/db/upgrade.php
version.php

index ba8dc13..5fa817d 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="type"/>
-        <FIELD NAME="type" TYPE="char" LENGTH="6" NOTNULL="true" SEQUENCE="false" COMMENT="Type of the backup (activity/section/course)" PREVIOUS="backupid" NEXT="itemid"/>
+        <FIELD NAME="type" TYPE="char" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="Type of the backup (activity/section/course)" PREVIOUS="backupid" NEXT="itemid"/>
         <FIELD NAME="itemid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="id of the module/section/activity being backup" PREVIOUS="type" NEXT="format"/>
         <FIELD NAME="format" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="format of the backup (moodle/imscc...)" PREVIOUS="itemid" NEXT="interactive"/>
         <FIELD NAME="interactive" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="is the backup interactive (1-yes/0-no)" PREVIOUS="format" NEXT="purpose"/>
index 6c87f0e..fc75267 100644 (file)
@@ -3665,6 +3665,37 @@ AND EXISTS (SELECT 'x'
         upgrade_main_savepoint($result, 2010042801);
     }
 
+    if ($result && $oldversion < 2010042802) { // Change backup_controllers->type to varchar10 (recreate dep. index)
+
+    /// Define index typeitem_ix (not unique) to be dropped form backup_controllers
+        $table = new xmldb_table('backup_controllers');
+        $index = new xmldb_index('typeitem_ix', XMLDB_INDEX_NOTUNIQUE, array('type', 'itemid'));
+
+    /// Conditionally launch drop index typeitem_ix
+        if ($dbman->index_exists($table, $index)) {
+            $dbman->drop_index($table, $index);
+        }
+
+    /// Changing precision of field type on table backup_controllers to (10)
+        $table = new xmldb_table('backup_controllers');
+        $field = new xmldb_field('type', XMLDB_TYPE_CHAR, '10', null, XMLDB_NOTNULL, null, null, 'backupid');
+
+    /// Launch change of precision for field type
+        $dbman->change_field_precision($table, $field);
+
+    /// Define index typeitem_ix (not unique) to be added to backup_controllers
+        $table = new xmldb_table('backup_controllers');
+        $index = new xmldb_index('typeitem_ix', XMLDB_INDEX_NOTUNIQUE, array('type', 'itemid'));
+
+    /// Conditionally launch add index typeitem_ix
+        if (!$dbman->index_exists($table, $index)) {
+            $dbman->add_index($table, $index);
+        }
+
+    /// Main savepoint reached
+        upgrade_main_savepoint($result, 2010042802);
+    }
+
     return $result;
 }
 
index b21399c..6c8b870 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 = 2010042801;  // YYYYMMDD   = date of the last version bump
+    $version = 2010042802;  // YYYYMMDD   = date of the last version bump
                             //         XX = daily increments
 
     $release = '2.0 dev (Build: 20100428)';  // Human-friendly version name