$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);
}