]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19701, MDL-19695 ddl stuff - review upgrade to enforce dependencies on every...
authorstronk7 <stronk7>
Thu, 30 Jul 2009 18:48:42 +0000 (18:48 +0000)
committerstronk7 <stronk7>
Thu, 30 Jul 2009 18:48:42 +0000 (18:48 +0000)
lib/db/upgrade.php

index b7a4c5b544a5830d3512426dc3325a2c1ad2f72d..dea7578a07ae82f4da0c996baf751d0f71ca96a5 100644 (file)
@@ -1077,9 +1077,25 @@ function xmldb_main_upgrade($oldversion) {
         $table = new xmldb_table('course_request');
         $field = new xmldb_field('shortname', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, 'fullname');
 
+    /// Before changing the field, drop dependent indexes
+    /// Define index shortname (not unique) to be dropped form course_request
+        $index = new xmldb_index('shortname', XMLDB_INDEX_NOTUNIQUE, array('shortname'));
+    /// Conditionally launch drop index shortname
+        if ($dbman->index_exists($table, $index)) {
+            $dbman->drop_index($table, $index);
+        }
+
     /// Launch change of precision for field shortname
         $dbman->change_field_precision($table, $field);
 
+    /// After changing the field, recreate dependent indexes
+    /// Define index shortname (not unique) to be added to course_request
+        $index = new xmldb_index('shortname', XMLDB_INDEX_NOTUNIQUE, array('shortname'));
+    /// Conditionally launch add index shortname
+        if (!$dbman->index_exists($table, $index)) {
+            $dbman->add_index($table, $index);
+        }
+
     /// Main savepoint reached
         upgrade_main_savepoint($result, 2008120700);
     }