blocks upgrade MDL-22693 Forgot to change the precision of the block_instances.pagetypepattern column to 64 chars. Do it now.

You have to drop and re-create the associated index, otherwise this will not work, at least on Postgres.
This commit is contained in:
Tim Hunt 2010-09-13 13:01:34 +00:00
parent 3108fdf0d4
commit 39c763645e
2 changed files with 45 additions and 1 deletions

View File

@ -5082,6 +5082,50 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
upgrade_main_savepoint(true, 2010082502);
}
if ($oldversion < 2010091300) {
// Need to drop the index before we can alter the column precision in the next step.
// Define index parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern (not unique) to be dropped form block_instances
$table = new xmldb_table('block_instances');
$index = new xmldb_index('parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern', XMLDB_INDEX_NOTUNIQUE, array('parentcontextid', 'showinsubcontexts', 'pagetypepattern', 'subpagepattern'));
// Conditionally launch drop index parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}
// Main savepoint reached
upgrade_main_savepoint(true, 2010091300);
}
if ($oldversion < 2010091301) {
// Changing precision of field pagetypepattern on table block_instances to (64)
$table = new xmldb_table('block_instances');
$field = new xmldb_field('pagetypepattern', XMLDB_TYPE_CHAR, '64', null, XMLDB_NOTNULL, null, null, 'showinsubcontexts');
// Launch change of precision for field pagetypepattern
$dbman->change_field_precision($table, $field);
// Main savepoint reached
upgrade_main_savepoint(true, 2010091301);
}
if ($oldversion < 2010091302) {
// Now add the index back.
// Define index parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern (not unique) to be added to block_instances
$table = new xmldb_table('block_instances');
$index = new xmldb_index('parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern', XMLDB_INDEX_NOTUNIQUE, array('parentcontextid', 'showinsubcontexts', 'pagetypepattern', 'subpagepattern'));
// Conditionally launch add index parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Main savepoint reached
upgrade_main_savepoint(true, 2010091302);
}
return true;
}

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2010091200; // YYYYMMDD = date of the last version bump
$version = 2010091302; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 Preview 4+ (Build: 20100913)'; // Human-friendly version name