From 72aeb83a74c7351d306718d274c6248a8c3399ec Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Tue, 15 Apr 2014 12:25:48 +0800 Subject: [PATCH] MDL-44998 log_standard: review indexes --- admin/tool/log/store/standard/db/install.xml | 9 +-- admin/tool/log/store/standard/db/upgrade.php | 69 ++++++++++++++++++++ admin/tool/log/store/standard/version.php | 2 +- 3 files changed, 73 insertions(+), 7 deletions(-) diff --git a/admin/tool/log/store/standard/db/install.xml b/admin/tool/log/store/standard/db/install.xml index 053f8cdcb80..9586c034b66 100644 --- a/admin/tool/log/store/standard/db/install.xml +++ b/admin/tool/log/store/standard/db/install.xml @@ -1,5 +1,5 @@ - @@ -33,11 +33,8 @@ - - - - - + + diff --git a/admin/tool/log/store/standard/db/upgrade.php b/admin/tool/log/store/standard/db/upgrade.php index db7a122262e..d394d4698f6 100644 --- a/admin/tool/log/store/standard/db/upgrade.php +++ b/admin/tool/log/store/standard/db/upgrade.php @@ -42,5 +42,74 @@ function xmldb_logstore_standard_upgrade($oldversion) { upgrade_plugin_savepoint(true, 2014032000, 'logstore', 'standard'); } + if ($oldversion < 2014041500) { + + // Define index contextid-component (not unique) to be dropped form logstore_standard_log. + $table = new xmldb_table('logstore_standard_log'); + $index = new xmldb_index('contextid-component', XMLDB_INDEX_NOTUNIQUE, array('contextid', 'component')); + + // Conditionally launch drop index contextid-component. + if ($dbman->index_exists($table, $index)) { + $dbman->drop_index($table, $index); + } + + // Define index courseid (not unique) to be dropped form logstore_standard_log. + $table = new xmldb_table('logstore_standard_log'); + $index = new xmldb_index('courseid', XMLDB_INDEX_NOTUNIQUE, array('courseid')); + + // Conditionally launch drop index courseid. + if ($dbman->index_exists($table, $index)) { + $dbman->drop_index($table, $index); + } + + // Define index eventname (not unique) to be dropped form logstore_standard_log. + $table = new xmldb_table('logstore_standard_log'); + $index = new xmldb_index('eventname', XMLDB_INDEX_NOTUNIQUE, array('eventname')); + + // Conditionally launch drop index eventname. + if ($dbman->index_exists($table, $index)) { + $dbman->drop_index($table, $index); + } + + // Define index crud (not unique) to be dropped form logstore_standard_log. + $table = new xmldb_table('logstore_standard_log'); + $index = new xmldb_index('crud', XMLDB_INDEX_NOTUNIQUE, array('crud')); + + // Conditionally launch drop index crud. + if ($dbman->index_exists($table, $index)) { + $dbman->drop_index($table, $index); + } + + // Define index edulevel (not unique) to be dropped form logstore_standard_log. + $table = new xmldb_table('logstore_standard_log'); + $index = new xmldb_index('edulevel', XMLDB_INDEX_NOTUNIQUE, array('edulevel')); + + // Conditionally launch drop index edulevel. + if ($dbman->index_exists($table, $index)) { + $dbman->drop_index($table, $index); + } + + // Define index course-time (not unique) to be added to logstore_standard_log. + $table = new xmldb_table('logstore_standard_log'); + $index = new xmldb_index('course-time', XMLDB_INDEX_NOTUNIQUE, array('courseid', 'anonymous', 'timecreated')); + + // Conditionally launch add index course-time. + if (!$dbman->index_exists($table, $index)) { + $dbman->add_index($table, $index); + } + + // Define index user-module (not unique) to be added to logstore_standard_log. + $table = new xmldb_table('logstore_standard_log'); + $index = new xmldb_index('user-module', XMLDB_INDEX_NOTUNIQUE, array('userid', 'contextlevel', 'contextinstanceid', 'crud', 'edulevel', 'timecreated')); + + // Conditionally launch add index user-module. + if (!$dbman->index_exists($table, $index)) { + $dbman->add_index($table, $index); + } + + // Standard savepoint reached. + upgrade_plugin_savepoint(true, 2014041500, 'logstore', 'standard'); + } + return true; } diff --git a/admin/tool/log/store/standard/version.php b/admin/tool/log/store/standard/version.php index 94f88e238da..32ba411164c 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 = 2014032000; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2014041500; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2014031200; // Requires this Moodle version. $plugin->component = 'logstore_standard'; // Full name of the plugin (used for diagnostics).