MDL-65436 message: fix error while upgrading legacy self-conversations

Delete self-messages from the legacy message_read table once they
are migrated.
This commit is contained in:
Sara Arjona 2019-04-29 07:53:07 +02:00
parent 14cdf51189
commit 50255ba981

View File

@ -3128,12 +3128,13 @@ function xmldb_main_upgrade($oldversion) {
$mua->timecreated = $message->timeread;
$DB->insert_record('message_user_actions', $mua);
// The self-conversation message has been migrated. Delete the record from the legacy table as soon as possible
// to avoid migrate it twice.
$DB->delete_records('message_read', ['id' => $message->id]);
}
$legacyselfmessagesrs->close();
// We can now delete the records from legacy table because the self-conversations have been migrated from the legacy tables.
$DB->delete_records_select('message_read', $select);
// STEP 3. For existing users without self-conversations, create and star it.
// Get all the users without a self-conversation.