diff --git a/admin/tool/monitor/db/install.xml b/admin/tool/monitor/db/install.xml index 1774e5895d1..da64419f0f8 100644 --- a/admin/tool/monitor/db/install.xml +++ b/admin/tool/monitor/db/install.xml @@ -1,5 +1,5 @@ - @@ -76,6 +76,9 @@ + + + diff --git a/admin/tool/monitor/db/upgrade.php b/admin/tool/monitor/db/upgrade.php index 248aea174bd..86781854f70 100644 --- a/admin/tool/monitor/db/upgrade.php +++ b/admin/tool/monitor/db/upgrade.php @@ -33,11 +33,41 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_tool_monitor_upgrade($oldversion) { global $CFG, $DB; + require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions. + + $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. + // Automatically generated Moodle v3.9.0 release upgrade line. // Put any upgrade step following this. // Automatically generated Moodle v4.0.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2022053000) { + + // Define key courseid (foreign) to be added to tool_monitor_events. + $table = new xmldb_table('tool_monitor_events'); + $key = new xmldb_key('courseid', XMLDB_KEY_FOREIGN, ['courseid'], 'course', ['id']); + + // Launch add key courseid. + $dbman->add_key($table, $key); + + // Define key contextid (foreign) to be added to tool_monitor_events. + $table = new xmldb_table('tool_monitor_events'); + $key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, ['contextid'], 'context', ['id']); + + // Launch add key contextid. + $dbman->add_key($table, $key); + + // Define key contextinstanceid (foreign) to be added to tool_monitor_events. + $table = new xmldb_table('tool_monitor_events'); + $key = new xmldb_key('contextinstanceid', XMLDB_KEY_FOREIGN, ['contextinstanceid'], 'context', ['instanceid']); + + // Launch add key contextinstanceid. + $dbman->add_key($table, $key); + + // Monitor savepoint reached. + upgrade_plugin_savepoint(true, 2022053000, 'tool', 'monitor'); + } return true; } diff --git a/admin/tool/monitor/version.php b/admin/tool/monitor/version.php index 7c0e0c6c33b..3397cbfcda5 100644 --- a/admin/tool/monitor/version.php +++ b/admin/tool/monitor/version.php @@ -26,6 +26,6 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2022041900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2022053000; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2022041200; // Requires this Moodle version. $plugin->component = 'tool_monitor'; // Full name of the plugin (used for diagnostics).