From 815e5fab3e1a0bbfd66a1f89c8b415bb81ab8c4a Mon Sep 17 00:00:00 2001 From: Daniel Nolte <> Date: Thu, 29 Feb 2024 19:10:03 +0100 Subject: [PATCH] fix(upgrade): Removed old indices (for legacy installations of the plugin). --- CHANGES.md | 3 +++ db/upgrade.php | 16 ++++++++++++++-- version.php | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f684a42..2f0c383 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,8 @@ ## Changelog ## +- [2.0.9]: + - Removed old indices (for legacy installations of the plugin). + - [2.0.8]: - Activity completion for views now possible. - Small last bugfixes. diff --git a/db/upgrade.php b/db/upgrade.php index 15de6ed..5bf4aae 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -41,12 +41,19 @@ function xmldb_exammanagement_upgrade($oldversion) { // Documentation for the XMLDB Editor can be found at: // https://docs.moodle.org/dev/XMLDB_editor. - if ($oldversion < 2024022300) { // Remove legacy field for plugininstanceid. + if ($oldversion < 2024022900) { // Remove legacy field for plugininstanceid. // Define field plugininstanceid to be removed to exammanagement_participants. $table = new xmldb_table('exammanagement_participants'); $field = new xmldb_field('plugininstanceid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); + $index = new xmldb_index('plugininstanceid', XMLDB_INDEX_NOTUNIQUE, ['plugininstanceid']); + + // Conditionally launch remove index. + if ($dbman->index_exists($table, $index)) { + $dbman->drop_index($table, $index); + } + // Conditionally launch remove field. if ($dbman->field_exists($table, $field)) { $dbman->drop_field($table, $field); @@ -55,12 +62,17 @@ function xmldb_exammanagement_upgrade($oldversion) { // Define field plugininstanceid to be removed to exammanagement. $table = new xmldb_table('exammanagement_temp_part'); + // Conditionally launch remove index. + if ($dbman->index_exists($table, $index)) { + $dbman->drop_index($table, $index); + } + // Conditionally launch remove field. if ($dbman->field_exists($table, $field)) { $dbman->drop_field($table, $field); } - upgrade_mod_savepoint(true, 2024022300, 'exammanagement'); + upgrade_mod_savepoint(true, 2024022900, 'exammanagement'); } return true; diff --git a/version.php b/version.php index d1053e7..2377cc9 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_exammanagement'; // Full name of the plugin (used for diagnostics). -$plugin->release = '2.0.8'; // User-friendly version number. -$plugin->version = 2024022800; // The current module version (Date: YYYYMMDDXX). +$plugin->release = '2.0.9'; // User-friendly version number. +$plugin->version = 2024022900; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2020061500; // Requires this Moodle version. $plugin->maturity = MATURITY_STABLE;