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 9b4247b9a4a..fc3b1bfcb12 100644
--- a/admin/tool/log/store/standard/db/upgrade.php
+++ b/admin/tool/log/store/standard/db/upgrade.php
@@ -123,5 +123,20 @@ function xmldb_logstore_standard_upgrade($oldversion) {
// Moodle v3.0.0 release upgrade line.
// Put any upgrade step following this.
+ if ($oldversion < 2015111601) {
+ // 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, 2015111601, 'logstore', 'standard');
+ }
+
return true;
}
diff --git a/admin/tool/log/store/standard/version.php b/admin/tool/log/store/standard/version.php
index 73c131e551e..e5cdc97a3a2 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 = 2015111601; // 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).