Skip to content

Commit

Permalink
Fix upgrade that MySQL could not cope with.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhunt committed Mar 1, 2007
1 parent 341e995 commit 31f6834
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions mod/quiz/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ function xmldb_quiz_upgrade($oldversion=0) {
/// this comment lines once this file start handling proper
/// upgrade code.

/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
/// $result = result of "/lib/ddllib.php" function calls
/// }

if ($result && $oldversion < 2007022800) {
/// Ensure that there are not existing duplicate entries in the database.
delete_records_select('question_numerical_units', "id > (SELECT MIN(iqnu.id)
$duplicateunits = get_records_select('question_numerical_units', "id > (SELECT MIN(iqnu.id)
FROM {$CFG->prefix}question_numerical_units iqnu
WHERE iqnu.question = {$CFG->prefix}question_numerical_units.question AND
iqnu.unit = {$CFG->prefix}question_numerical_units.unit)");
iqnu.unit = {$CFG->prefix}question_numerical_units.unit)", '', 'id');
if ($duplicateunits) {
delete_records_select('question_numerical_units', 'id IN (' . implode(',', array_keys($duplicateunits)) . ')');
}

/// Define index question-unit (unique) to be added to question_numerical_units
$table = new XMLDBTable('question_numerical_units');
Expand Down

0 comments on commit 31f6834

Please sign in to comment.