MDL-69572 mod_book : add bookid index to book_chapters

This commit is contained in:
Nathan Nguyen
2020-10-01 23:28:21 +01:00
committed by Víctor Déniz
parent 8d371859dc
commit 946159a554
3 changed files with 17 additions and 3 deletions
+4 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/book/db" VERSION="20120515" COMMENT="XMLDB file for Moodle mod_book"
<XMLDB PATH="mod/book/db" VERSION="20200907" COMMENT="XMLDB file for Moodle mod_book"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
@@ -39,6 +39,9 @@
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="bookid" UNIQUE="false" FIELDS="bookid"/>
</INDEXES>
</TABLE>
</TABLES>
</XMLDB>
+12 -1
View File
@@ -30,7 +30,9 @@ defined('MOODLE_INTERNAL') || die;
* @return bool always true
*/
function xmldb_book_upgrade($oldversion) {
global $CFG;
global $CFG, $DB;
$dbman = $DB->get_manager();
// Automatically generated Moodle v3.5.0 release upgrade line.
// Put any upgrade step following this.
@@ -47,5 +49,14 @@ function xmldb_book_upgrade($oldversion) {
// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2020100100) {
$table = new xmldb_table('book_chapters');
$index = new xmldb_index('bookid', XMLDB_INDEX_NOTUNIQUE, ['bookid']);
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
upgrade_mod_savepoint(true, 2020100100, 'book');
}
return true;
}
+1 -1
View File
@@ -25,6 +25,6 @@
defined('MOODLE_INTERNAL') || die;
$plugin->component = 'mod_book'; // Full name of the plugin (used for diagnostics)
$plugin->version = 2020061500; // The current module version (Date: YYYYMMDDXX)
$plugin->version = 2020100100; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2020060900; // Requires this Moodle version
$plugin->cron = 0; // Period for cron to check this module (secs)