Commit 0bb33628 authored by Aaron Wells's avatar Aaron Wells
Browse files

Flexible layout upgrade compatibility for pre-1.2 Mahara sites

Bug1238363

Change-Id: Ib99b684a5d23aa943a37b28706ba1ba7ac8c3f48
parent 03c0b94f
......@@ -3322,9 +3322,22 @@ function xmldb_core_upgrade($oldversion=0) {
$field = new XMLDBField('row');
$field->setAttributes(XMLDB_TYPE_INTEGER, 2, null, XMLDB_NOTNULL, null, null, null, 1);
add_field($table, $field);
// Refactor the block_instance.viewcolumnorderuk key so it includes row.
$key = new XMLDBKey('viewcolumnorderuk');
$key->setAttributes(XMLDB_KEY_UNIQUE, array('view', 'column', 'order'));
drop_key($table, $key);
// If this particular site has been around since before Mahara 1.2, this
// will actually have been created as a unique index rather than a unique
// key, so check for that first.
$indexname = find_index_name($table, $key);
if (preg_match('/uix$/', $indexname)) {
$index = new XMLDBIndex($indexname);
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('view', 'column', 'order'));
drop_index($table, $index);
}
else {
drop_key($table, $key);
}
$key = new XMLDBKey('viewrowcolumnorderuk');
$key->setAttributes(XMLDB_KEY_UNIQUE, array('view', 'row', 'column', 'order'));
add_key($table, $key);
......
Supports Markdown
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