From c1f3f5a2049a03a40c5fed7b7b5e743716444b76 Mon Sep 17 00:00:00 2001 From: Kevin Pham Date: Tue, 23 Nov 2021 12:15:21 +1100 Subject: [PATCH] Add missing foreign key for 'stepconfigid' upgrades Issue when upgrading from a lower version - started from 01950e69828864dad74891b8418a584a11f632ea --- db/upgrade.php | 15 +++++++++++++++ version.php | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/db/upgrade.php b/db/upgrade.php index 869517e..7a0066c 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -337,5 +337,20 @@ function xmldb_tool_trigger_upgrade($oldversion) { upgrade_plugin_savepoint(true, 2021030403, 'tool', 'trigger'); } + if ($oldversion < 2021030404) { + + // Define key stepconfigid (foreign) to be added to tool_trigger_run_hist. + $table = new xmldb_table('tool_trigger_run_hist'); + $key = new xmldb_key('stepconfigid', XMLDB_KEY_FOREIGN, ['stepconfigid'], 'tool_trigger_steps', ['id']); + + // Launch add key stepconfigid. + if (!$table->getKey($key->getName())) { + $dbman->add_key($table, $key); + } + + // Trigger savepoint reached. + upgrade_plugin_savepoint(true, 2021030404, 'tool', 'trigger'); + } + return true; } diff --git a/version.php b/version.php index 72f6273..1eb1493 100755 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'tool_trigger'; -$plugin->release = 2021030403; -$plugin->version = 2021030403; +$plugin->release = 2021030404; +$plugin->version = 2021030404; $plugin->requires = 2016052300; $plugin->maturity = MATURITY_STABLE; $plugin->dependencies = array('tool_monitor' => 2015051101);