Skip to content

Commit

Permalink
MDL-57370 message: change indexes on message tables
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwyllie committed Feb 7, 2017
1 parent 4d146f1 commit 98be2d2
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 6 deletions.
8 changes: 5 additions & 3 deletions lib/db/install.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20161119" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20170207" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
Expand Down Expand Up @@ -545,8 +545,9 @@
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="useridto" UNIQUE="false" FIELDS="useridto"/>
<INDEX NAME="useridfromtodeleted" UNIQUE="false" FIELDS="useridfrom, useridto, timeuserfromdeleted, timeusertodeleted"/>
<INDEX NAME="useridfrom_timeuserfromdeleted_notification" UNIQUE="false" FIELDS="useridfrom, timeuserfromdeleted, notification"/>
<INDEX NAME="useridto_timeusertodeleted_notification" UNIQUE="false" FIELDS="useridto, timeusertodeleted, notification"/>
</INDEXES>
</TABLE>
<TABLE NAME="message_read" COMMENT="Stores all messages that have been read">
Expand All @@ -573,9 +574,10 @@
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="useridto" UNIQUE="false" FIELDS="useridto"/>
<INDEX NAME="useridfromtodeleted" UNIQUE="false" FIELDS="useridfrom, useridto, timeuserfromdeleted, timeusertodeleted"/>
<INDEX NAME="notificationtimeread" UNIQUE="false" FIELDS="notification, timeread"/>
<INDEX NAME="useridfrom_timeuserfromdeleted_notification" UNIQUE="false" FIELDS="useridfrom, timeuserfromdeleted, notification"/>
<INDEX NAME="useridto_timeusertodeleted_notification" UNIQUE="false" FIELDS="useridto, timeusertodeleted, notification"/>
</INDEXES>
</TABLE>
<TABLE NAME="message_contacts" COMMENT="Maintains lists of relationships between users">
Expand Down
60 changes: 60 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2465,5 +2465,65 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2016122800.00);
}

if ($oldversion < 2017020200.01) {

// Define index useridfrom_timeuserfromdeleted_notification (not unique) to be added to message.
$table = new xmldb_table('message');
$index = new xmldb_index('useridfrom_timeuserfromdeleted_notification', XMLDB_INDEX_NOTUNIQUE, array('useridfrom', 'timeuserfromdeleted', 'notification'));

// Conditionally launch add index useridfrom_timeuserfromdeleted_notification.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}

// Define index useridto_timeusertodeleted_notification (not unique) to be added to message.
$index = new xmldb_index('useridto_timeusertodeleted_notification', XMLDB_INDEX_NOTUNIQUE, array('useridto', 'timeusertodeleted', 'notification'));

// Conditionally launch add index useridto_timeusertodeleted_notification.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}

$index = new xmldb_index('useridto', XMLDB_INDEX_NOTUNIQUE, array('useridto'));

// Conditionally launch drop index useridto.
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}

// Main savepoint reached.
upgrade_main_savepoint(true, 2017020200.01);
}

if ($oldversion < 2017020200.02) {

// Define index useridfrom_timeuserfromdeleted_notification (not unique) to be added to message_read.
$table = new xmldb_table('message_read');
$index = new xmldb_index('useridfrom_timeuserfromdeleted_notification', XMLDB_INDEX_NOTUNIQUE, array('useridfrom', 'timeuserfromdeleted', 'notification'));

// Conditionally launch add index useridfrom_timeuserfromdeleted_notification.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}

// Define index useridto_timeusertodeleted_notification (not unique) to be added to message_read.
$index = new xmldb_index('useridto_timeusertodeleted_notification', XMLDB_INDEX_NOTUNIQUE, array('useridto', 'timeusertodeleted', 'notification'));

// Conditionally launch add index useridto_timeusertodeleted_notification.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}

$index = new xmldb_index('useridto', XMLDB_INDEX_NOTUNIQUE, array('useridto'));

// Conditionally launch drop index useridto.
if ($dbman->index_exists($table, $index)) {
$dbman->drop_index($table, $index);
}

// Main savepoint reached.
upgrade_main_savepoint(true, 2017020200.02);
}

return true;
}
3 changes: 2 additions & 1 deletion message/output/popup/db/install.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="message/output/popup/db" VERSION="20160729" COMMENT="XMLDB file for Moodle message/output/popup"
<XMLDB PATH="message/output/popup/db" VERSION="20161221" COMMENT="XMLDB file for Moodle message/output/popup"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
>
Expand All @@ -15,6 +15,7 @@
</KEYS>
<INDEXES>
<INDEX NAME="messageid-isread" UNIQUE="true" FIELDS="messageid, isread"/>
<INDEX NAME="isread" UNIQUE="false" FIELDS="isread"/>
</INDEXES>
</TABLE>
</TABLES>
Expand Down
15 changes: 15 additions & 0 deletions message/output/popup/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,20 @@ function xmldb_message_popup_upgrade($oldversion) {
// Automatically generated Moodle v3.2.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2016122100) {

// Define index isread (not unique) to be added to message_popup.
$table = new xmldb_table('message_popup');
$index = new xmldb_index('isread', XMLDB_INDEX_NOTUNIQUE, array('isread'));

// Conditionally launch add index isread.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}

// Popup savepoint reached.
upgrade_plugin_savepoint(true, 2016122100, 'message', 'popup');
}

return true;
}
2 changes: 1 addition & 1 deletion message/output/popup/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2016120500; // The current plugin version (Date: YYYYMMDDXX)
$plugin->version = 2016122100; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2016112900; // Requires this Moodle version
$plugin->component = 'message_popup'; // Full name of the plugin (used for diagnostics)
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2017020200.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2017020200.02; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.

Expand Down

0 comments on commit 98be2d2

Please sign in to comment.