mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 01:46:45 +02:00
MDL-70285 completion upgrade: fix performance of the MDL-69687 code
This commit is contained in:
parent
87bcff8c6e
commit
86669b0564
1 changed files with 6 additions and 5 deletions
|
@ -2592,11 +2592,12 @@ function xmldb_main_upgrade($oldversion) {
|
|||
if ($oldversion < 2020061502.09) {
|
||||
// Delete orphaned course_modules_completion rows; these were not deleted properly
|
||||
// by remove_course_contents function.
|
||||
$DB->delete_records_subquery('course_modules_completion', 'id', 'id',
|
||||
"SELECT cmc.id
|
||||
FROM {course_modules_completion} cmc
|
||||
LEFT JOIN {course_modules} cm ON cm.id = cmc.coursemoduleid
|
||||
WHERE cm.id IS NULL");
|
||||
$DB->delete_records_select('course_modules_completion', "
|
||||
NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM {course_modules} cm
|
||||
WHERE cm.id = {course_modules_completion}.coursemoduleid
|
||||
)");
|
||||
upgrade_main_savepoint(true, 2020061502.09);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue