]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19695 field dependencies - before committing the dependency checker, fix all...
authorstronk7 <stronk7>
Thu, 2 Jul 2009 16:05:47 +0000 (16:05 +0000)
committerstronk7 <stronk7>
Thu, 2 Jul 2009 16:05:47 +0000 (16:05 +0000)
that will break once running with dependencies enabled

lib/db/upgrade.php

index ec55e06b87a165d8951cda1993f6239d18adae00..0fdd39d60371253da635f1ca545c63ea3c2c50f6 100644 (file)
@@ -2112,12 +2112,24 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
     /// Define field blockid to be dropped from block_instances
         $field = new xmldb_field('blockid');
         if ($dbman->field_exists($table, $field)) {
+        /// Before dropping the field, drop dependent indexes
+            $index = new xmldb_index('blockid', XMLDB_INDEX_NOTUNIQUE, array('blockid'));
+            if ($dbman->index_exists($table, $index)) {
+            /// Launch drop index blockid
+                $dbman->drop_index($table, $index);
+            }
             $dbman->drop_field($table, $field);
         }
 
     /// Define field pageid to be dropped from block_instances
         $field = new xmldb_field('pageid');
         if ($dbman->field_exists($table, $field)) {
+        /// Before dropping the field, drop dependent indexes
+            $index = new xmldb_index('pageid', XMLDB_INDEX_NOTUNIQUE, array('pageid'));
+            if ($dbman->index_exists($table, $index)) {
+            /// Launch drop index pageid
+                $dbman->drop_index($table, $index);
+            }
             $dbman->drop_field($table, $field);
         }