From 7d7e37ab3bf57c487ce549ba1165fa8be6b81aa8 Mon Sep 17 00:00:00 2001 From: Tomo Tsuyuki Date: Tue, 16 Nov 2021 15:01:53 +1100 Subject: [PATCH] Fix issue #98 to add a key --- db/upgrade.php | 13 +++++++++++++ version.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/db/upgrade.php b/db/upgrade.php index 645894b..fa07d7e 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -259,5 +259,18 @@ function xmldb_report_customsql_upgrade($oldversion) { upgrade_plugin_savepoint(true, 2021051000, 'report', 'customsql'); } + if ($oldversion < 2021111600) { + // Define index usermodified to be added to report_customsql_queries. + $table = new xmldb_table('report_customsql_queries'); + // Conditionally launch add key usermodified. + if (!$table->getKey('usermodified')) { + $key = new xmldb_key('usermodified', XMLDB_KEY_FOREIGN, ['usermodified'], 'user', ['id']); + $dbman->add_key($table, $key); + } + + // Customsql savepoint reached. + upgrade_plugin_savepoint(true, 2021111600, 'report', 'customsql'); + } + return true; } diff --git a/version.php b/version.php index 860bb9c..44aee34 100644 --- a/version.php +++ b/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2021070700; +$plugin->version = 2021111600; $plugin->requires = 2020061500; $plugin->component = 'report_customsql'; $plugin->maturity = MATURITY_STABLE;