MDL-61605 quiz report: add missing index/key
[moodle.git] / mod / quiz / report / overview / db / upgrade.php
CommitLineData
aeb15530 1<?php
e24ee794
TH
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Quiz overview report upgrade script.
19 *
8d76124c
TH
20 * @package quiz_overview
21 * @copyright 2008 Jamie Pratt
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
e24ee794
TH
23 */
24
a17b297d
TH
25defined('MOODLE_INTERNAL') || die();
26
e24ee794
TH
27/**
28 * Quiz overview report upgrade function.
29 * @param number $oldversion
a17b297d
TH
30 */
31function xmldb_quiz_overview_upgrade($oldversion) {
d9b80a5e
TH
32 global $DB;
33
34 $dbman = $DB->get_manager();
f94891cc 35
75c57a08
EL
36 // Automatically generated Moodle v3.2.0 release upgrade line.
37 // Put any upgrade step following this.
38
5e272283
EL
39 // Automatically generated Moodle v3.3.0 release upgrade line.
40 // Put any upgrade step following this.
41
6499085f
EL
42 // Automatically generated Moodle v3.4.0 release upgrade line.
43 // Put any upgrade step following this.
44
d9b80a5e
TH
45 if ($oldversion < 2018021800) {
46
47 // Define key questionusageid-slot (foreign-unique) to be added to quiz_overview_regrades.
48 $table = new xmldb_table('quiz_overview_regrades');
49 $key = new xmldb_key('questionusageid-slot', XMLDB_KEY_FOREIGN_UNIQUE, array('questionusageid', 'slot'), 'question_attempts', array('questionusageid', 'slot'));
50
51 // Launch add key questionusageid-slot.
52 $dbman->add_key($table, $key);
53
54 // Overview savepoint reached.
55 upgrade_plugin_savepoint(true, 2018021800, 'quiz', 'overview');
56 }
57
e24ee794
TH
58 return true;
59}