From 581e66373abbf401c739b1f1f37315c3f3fc9235 Mon Sep 17 00:00:00 2001 From: Davo Smith Date: Tue, 15 Sep 2015 10:49:05 +0100 Subject: [PATCH] MDL-51412 question: add index to qtype field --- lib/db/install.xml | 5 ++++- lib/db/upgrade.php | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/db/install.xml b/lib/db/install.xml index 837a7559d5294..b8de826dbc7b0 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -1,5 +1,5 @@ - @@ -1248,6 +1248,9 @@ + + + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 221943a32b43b..52567f28bc789 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -4558,5 +4558,19 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2015090801.00); } + if ($oldversion < 2015091500.00) { + // Define index qtype (not unique) to be added to question. + $table = new xmldb_table('question'); + $index = new xmldb_index('qtype', XMLDB_INDEX_NOTUNIQUE, array('qtype')); + + // Conditionally launch add index qtype. + if (!$dbman->index_exists($table, $index)) { + $dbman->add_index($table, $index); + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2015091500.00); + } + return true; }