MDL-11555 temporary patch for too long index on mysql - in mysql the limit is 333 unicode chars

move the gradebook cleanup to the end of upgrade.php - please keep it there
This commit is contained in:
skodak 2007-10-02 16:20:45 +00:00
parent 1ce61506e5
commit 266f6b5900
3 changed files with 56 additions and 23 deletions

View File

@ -1719,7 +1719,8 @@
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="typename" UNIQUE="true" FIELDS="flagtype, name"/>
<INDEX NAME="flagtype" UNIQUE="false" FIELDS="flagtype"/>
<INDEX NAME="name" UNIQUE="false" FIELDS="name"/>
</INDEXES>
</TABLE>
</TABLES>

View File

@ -2258,7 +2258,6 @@ function xmldb_main_upgrade($oldversion=0) {
if ($result && $oldversion < 2007100100) {
/// Define table cache_flags to be created
$table = new XMLDBTable('cache_flags');
@ -2273,31 +2272,19 @@ function xmldb_main_upgrade($oldversion=0) {
/// Adding keys to table cache_flags
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/*
* Note: mysql can not create indexes on text fields larger than 333 chars!
*/
/// Adding indexes to table cache_flags
$table->addIndexInfo('typename', XMLDB_INDEX_UNIQUE, array('flagtype', 'name'));
$table->addIndexInfo('flagtype', XMLDB_INDEX_NOTUNIQUE, array('flagtype'));
$table->addIndexInfo('name', XMLDB_INDEX_NOTUNIQUE, array('name'));
/// Launch create table for cache_flags
$result = $result && create_table($table);
}
/*
/// drop old gradebook tables
if ($result && $oldversion < xxxxxxxx) {
$tables = array('grade_category',
'grade_item',
'grade_letter',
'grade_preferences',
'grade_exceptions');
foreach ($tables as $table) {
$table = new XMLDBTable($table);
if (table_exists($table)) {
drop_table($table);
}
if (!table_exists($table)) {
$result = $result && create_table($table);
}
}
*/
if ($oldversion < 2007100300) {
//
@ -2318,6 +2305,51 @@ function xmldb_main_upgrade($oldversion=0) {
$result = $result && add_field($table, $field);
}
if ($result && $oldversion < 2007100301) {
/// Define table cache_flags to be created
$table = new XMLDBTable('cache_flags');
$index = new XMLDBIndex('typename');
if (index_exists($table, $index)) {
$result = $result && drop_index($table, $index);
}
$table = new XMLDBTable('cache_flags');
$index = new XMLDBIndex('flagtype');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('flagtype'));
if (!index_exists($table, $index)) {
$result = $result && add_index($table, $index);
}
$table = new XMLDBTable('cache_flags');
$index = new XMLDBIndex('name');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('name'));
if (!index_exists($table, $index)) {
$result = $result && add_index($table, $index);
}
}
/* NOTE: please keep this at the end of upgrade file for now ;-)
/// drop old gradebook tables
if ($result && $oldversion < xxxxxxxx) {
$tables = array('grade_category',
'grade_item',
'grade_letter',
'grade_preferences',
'grade_exceptions');
foreach ($tables as $table) {
$table = new XMLDBTable($table);
if (table_exists($table)) {
drop_table($table);
}
}
}
*/
return $result;
}

View File

@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
$version = 2007100300; // YYYYMMDD = date
$version = 2007100301; // YYYYMMDD = date
// XY = increments within a single day
$release = '1.9 Beta +'; // Human-friendly version name