Commit 4b152ba5 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Restore unique index on username column of the usr table (bug #784322)



An earlier upgrade to make the username column wider may have resulted
in a dropped index (see bug #548165).

This change will recreate the index if it's not there.

Change-Id: Iefc93b1bc05904498a2600ab9516c94ab6b26d42
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent a66aa0a6
......@@ -2266,6 +2266,8 @@ function xmldb_core_upgrade($oldversion=0) {
$table = new XMLDBTable('usr');
$field = new XMLDBField('username');
$field->setAttributes(XMLDB_TYPE_CHAR, 255, null, XMLDB_NOTNULL);
// This drops the unique index on the username column in postgres.
// See upgrade 2011051800.
change_field_precision($table, $field);
}
......@@ -2287,5 +2289,23 @@ function xmldb_core_upgrade($oldversion=0) {
delete_records('blocktype_category', 'name', 'feeds');
}
if ($oldversion < 2011051800) {
// Restore index that may be missing due to upgrade 2011050600.
$table = new XMLDBTable('usr');
$index = new XMLDBIndex('usr_use_uix');
if (!index_exists($table, $index)) {
if (is_postgres()) {
// For postgres, create the index on the lowercase username, the way it's
// done in core_postinst().
execute_sql('CREATE UNIQUE INDEX {usr_use_uix} ON {usr}(LOWER(username))');
}
else {
$index = new XMLDBIndex('usernameuk');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('username'));
add_index($table, $index);
}
}
}
return $status;
}
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2011051700;
$config->version = 2011051800;
$config->release = '1.4.0alpha2dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment