MDL-85034 core_course: Add index to course_sections for mod_subsection

This is a backport of MDL-84844.
This commit is contained in:
Philipp Memmel
2025-05-09 07:25:20 +02:00
parent 6dd1f61866
commit 27c4ebdace
2 changed files with 14 additions and 1 deletions
+2 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20240923" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20250506" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
@@ -395,6 +395,7 @@
</KEYS>
<INDEXES>
<INDEX NAME="course_section" UNIQUE="true" FIELDS="course, section"/>
<INDEX NAME="component_itemid" UNIQUE="false" FIELDS="component, itemid" COMMENT="necessary for querying delegated sections"/>
</INDEXES>
</TABLE>
<TABLE NAME="course_request" COMMENT="course requests">
+12
View File
@@ -1489,5 +1489,17 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2024100702.03);
}
if ($oldversion < 2024100704.05) {
// Add index for querying delegated sections.
$table = new xmldb_table('course_sections');
$index = new xmldb_index('component_itemid', XMLDB_INDEX_NOTUNIQUE, ['component', 'itemid']);
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2024100704.05);
}
return true;
}