mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
MDL-63211 core: upgrade to remove duplicate contacts
Remove any duplicate rows - from now on adding contacts just requires 1 row. The person who made the contact request (userid) and the person who approved it (contactid). Upgrade the table so that the first person to add the contact was the one who made the request.
This commit is contained in:
parent
3ec5c7701c
commit
b65bfc8ab4
@ -2505,5 +2505,24 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2018092800.02);
|
||||
}
|
||||
|
||||
if ($oldversion < 2018092800.03) {
|
||||
// Remove any duplicate rows - from now on adding contacts just requires 1 row.
|
||||
// The person who made the contact request (userid) and the person who approved
|
||||
// it (contactid). Upgrade the table so that the first person to add the contact
|
||||
// was the one who made the request.
|
||||
$sql = "SELECT c1.id
|
||||
FROM {message_contacts} c1
|
||||
INNER JOIN {message_contacts} c2
|
||||
ON c1.userid = c2.contactid
|
||||
AND c1.contactid = c2.userid
|
||||
WHERE c1.id > c2.id";
|
||||
if ($contacts = $DB->get_records_sql($sql)) {
|
||||
list($insql, $inparams) = $DB->get_in_or_equal(array_keys($contacts));
|
||||
$DB->delete_records_select('message_contacts', "id $insql", $inparams);
|
||||
}
|
||||
|
||||
upgrade_main_savepoint(true, 2018092800.03);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2018092800.02; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2018092800.03; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user