From e214f22f3931d44676e9b7f6ab9c17b292bfdfc8 Mon Sep 17 00:00:00 2001 From: Eric Merrill Date: Tue, 12 Apr 2016 21:44:15 -0400 Subject: [PATCH] MDL-53795 logging: Add DB index for use when backing up logs --- admin/tool/log/store/standard/db/install.xml | 1 + admin/tool/log/store/standard/db/upgrade.php | 19 ++++++++++++++++++- admin/tool/log/store/standard/version.php | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/admin/tool/log/store/standard/db/install.xml b/admin/tool/log/store/standard/db/install.xml index 9586c034b66..22d80d4e06e 100644 --- a/admin/tool/log/store/standard/db/install.xml +++ b/admin/tool/log/store/standard/db/install.xml @@ -30,6 +30,7 @@ + diff --git a/admin/tool/log/store/standard/db/upgrade.php b/admin/tool/log/store/standard/db/upgrade.php index b844b6271c4..4e23361aecd 100644 --- a/admin/tool/log/store/standard/db/upgrade.php +++ b/admin/tool/log/store/standard/db/upgrade.php @@ -25,7 +25,9 @@ defined('MOODLE_INTERNAL') || die(); function xmldb_logstore_standard_upgrade($oldversion) { - global $CFG; + global $CFG, $DB; + + $dbman = $DB->get_manager(); // Moodle v2.8.0 release upgrade line. // Put any upgrade step following this. @@ -36,5 +38,20 @@ function xmldb_logstore_standard_upgrade($oldversion) { // Moodle v3.0.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2016041200) { + // This could take a long time. Unfortunately, no way to know how long, and no way to do progress, so setting for 1 hour. + upgrade_set_timeout(3600); + + // Define key contextid (foreign) to be added to logstore_standard_log. + $table = new xmldb_table('logstore_standard_log'); + $key = new xmldb_key('contextid', XMLDB_KEY_FOREIGN, array('contextid'), 'context', array('id')); + + // Launch add key contextid. + $dbman->add_key($table, $key); + + // Standard savepoint reached. + upgrade_plugin_savepoint(true, 2016041200, 'logstore', 'standard'); + } + return true; } diff --git a/admin/tool/log/store/standard/version.php b/admin/tool/log/store/standard/version.php index 73c131e551e..2e482f470fb 100644 --- a/admin/tool/log/store/standard/version.php +++ b/admin/tool/log/store/standard/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2015111600; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2016041200; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2015111000; // Requires this Moodle version. $plugin->component = 'logstore_standard'; // Full name of the plugin (used for diagnostics).