From 006ad26e71a33f9f516cf6cb787c8702dd307009 Mon Sep 17 00:00:00 2001 From: Jose Su Date: Tue, 4 Nov 2025 11:40:42 +0100 Subject: [PATCH] MT#63462 Remove duplicate prosody table entries In some cases, the prosody.prosody table contains duplicated entries. This causes the 15841.up migration script to fail when creating the new index. To prevent this, add a step before dropping/creating the index to remove all duplicate rows from the table. Change-Id: I912dd8484231689d5b1f3dc5087bb69a96c496eb (cherry picked from commit 1bf0fbf03af3252622b5bcdd342e5b71e674285f) (cherry picked from commit de7eb09ed5dd47a6f7c2d3b9d0bffd0e12f4835e) --- db_scripts/diff/15841.up | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/db_scripts/diff/15841.up b/db_scripts/diff/15841.up index d4ff9fc7..d846e07e 100644 --- a/db_scripts/diff/15841.up +++ b/db_scripts/diff/15841.up @@ -1,6 +1,16 @@ USE prosody; SET autocommit=0; +DELETE FROM prosody +WHERE (host, user, store, `key`, `value`) NOT IN ( + SELECT t.host, t.user, t.store, t.`key`, t.max_value + FROM ( + SELECT host, user, store, `key`, MAX(value) AS max_value + FROM prosody + GROUP BY host, user, store, `key` + ) AS t +); + DROP INDEX prosody_index on prosody; CREATE UNIQUE INDEX prosody_unique_index ON prosody(`host`(20), `user`(20), `store`(20), `key`(20)) USING BTREE; COMMIT;