diff --git a/install/froxlor.sql b/install/froxlor.sql index e6214ef6..b62423cc 100644 --- a/install/froxlor.sql +++ b/install/froxlor.sql @@ -705,7 +705,7 @@ opcache.interned_strings_buffer'), ('panel', 'customer_hide_options', ''), ('panel', 'is_configured', '0'), ('panel', 'version', '0.10.16'), - ('panel', 'db_version', '202004140'); + ('panel', 'db_version', '202005150'); DROP TABLE IF EXISTS `panel_tasks`; @@ -997,7 +997,8 @@ CREATE TABLE IF NOT EXISTS `domain_ssl_settings` ( `ssl_csr_file` mediumtext, `ssl_fullchain_file` mediumtext, `expirationdate` datetime DEFAULT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + UNIQUE KEY (`domainid`) ) ENGINE=InnoDB CHARSET=utf8 COLLATE=utf8_general_ci; 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 8541feb4..e7d26e6e 100644 --- a/install/updates/froxlor/0.10/update_0.10.inc.php +++ b/install/updates/froxlor/0.10/update_0.10.inc.php @@ -617,3 +617,20 @@ if (\Froxlor\Froxlor::isFroxlorVersion('0.10.15')) { showUpdateStep("Updating from 0.10.15 to 0.10.16", false); \Froxlor\Froxlor::updateToVersion('0.10.16'); } + +if (\Froxlor\Froxlor::isDatabaseVersion('202004140')) { + + showUpdateStep("Adding unique key on domainid field in domain ssl table"); + // 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`)) + WHERE b.`id` IS NOT NULL + GROUP BY a.`id` + "); + Database::query("ALTER TABLE `domain_ssl_settings` ADD UNIQUE(`domainid`)"); + lastStepStatus(0); + + \Froxlor\Froxlor::updateToDbVersion('202005150'); +} diff --git a/lib/Froxlor/Froxlor.php b/lib/Froxlor/Froxlor.php index b333b3c6..034c9374 100644 --- a/lib/Froxlor/Froxlor.php +++ b/lib/Froxlor/Froxlor.php @@ -10,7 +10,7 @@ final class Froxlor const VERSION = '0.10.16'; // Database version (YYYYMMDDC where C is a daily counter) - const DBVERSION = '202004140'; + const DBVERSION = '202005150'; // Distribution branding-tag (used for Debian etc.) const BRANDING = '';