From ffa9205f9547dffa4a86d3fdbabd9122e4b081e6 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Mon, 18 May 2020 20:48:48 +0200 Subject: [PATCH] fix sql query to remove duplicates before setting unique key in updater, fixes #840 Signed-off-by: Michael Kaufmann --- install/updates/froxlor/0.10/update_0.10.inc.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install/updates/froxlor/0.10/update_0.10.inc.php b/install/updates/froxlor/0.10/update_0.10.inc.php index 0c966205..7cdafb40 100644 --- a/install/updates/froxlor/0.10/update_0.10.inc.php +++ b/install/updates/froxlor/0.10/update_0.10.inc.php @@ -624,8 +624,9 @@ if (\Froxlor\Froxlor::isDatabaseVersion('202004140')) { // check for duplicate entries prior to set a unique key to avoid errors on update Database::query(" DELETE a.* FROM domain_ssl_settings AS a - LEFT JOIN domain_ssl_settings AS b ON UNIX_TIMESTAMP(b.`expirationdate`) > UNIX_TIMESTAMP(a.`expirationdate`) - AND (b.`domainid`=a.`domainid` OR (UNIX_TIMESTAMP(b.`expirationdate`) = UNIX_TIMESTAMP(a.`expirationdate`) AND b.`id`>a.`id`)) + LEFT JOIN domain_ssl_settings AS b ON + ((b.`domainid`=a.`domainid` AND UNIX_TIMESTAMP(b.`expirationdate`) > UNIX_TIMESTAMP(a.`expirationdate`)) + OR (UNIX_TIMESTAMP(b.`expirationdate`) = UNIX_TIMESTAMP(a.`expirationdate`) AND b.`id`>a.`id`)) WHERE b.`id` IS NOT NULL "); Database::query("ALTER TABLE `domain_ssl_settings` ADD UNIQUE(`domainid`)");