From bbea936991740a28bd203d40f2caa1cb321eb9cf Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Fri, 8 Aug 2014 13:56:23 +0100 Subject: [PATCH] MDL-45642 questions: add required index to question_attempts. It is important to be able to tell which behaviours are in use, and without this index, it requires a complete scan of this table, which can be very big, to verify that a behaviour is unused. --- lib/db/install.xml | 3 ++- lib/db/upgrade.php | 15 +++++++++++++++ version.php | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index ac9693e5b70..21490f84781 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -1323,6 +1323,7 @@ + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 5d88ee49a47..4a9c741a1c2 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -3719,5 +3719,20 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2014072400.01); } + if ($oldversion < 2014080801.00) { + + // Define index behaviour (not unique) to be added to question_attempts. + $table = new xmldb_table('question_attempts'); + $index = new xmldb_index('behaviour', XMLDB_INDEX_NOTUNIQUE, array('behaviour')); + + // Conditionally launch add index behaviour. + if (!$dbman->index_exists($table, $index)) { + $dbman->add_index($table, $index); + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2014080801.00); + } + return true; } diff --git a/version.php b/version.php index 81f07c94397..8c92a7a3e36 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2014080700.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2014080801.00; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes.