From: stronk7 Date: Thu, 2 Jul 2009 16:05:47 +0000 (+0000) Subject: MDL-19695 field dependencies - before committing the dependency checker, fix all... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4276a19a781923df98c3cccbfd7fe8b48c988f19;p=moodle.git MDL-19695 field dependencies - before committing the dependency checker, fix all places in upgrade that will break once running with dependencies enabled --- diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index ec55e06b87..0fdd39d603 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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); }