From 4cc9e637d3157da84540658ee14315ab8910af80 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 9 Dec 2015 13:11:40 -0800 Subject: [PATCH] FourSeven Upgrade - Protect against duplicate "navigation" settings --- CRM/Upgrade/Incremental/php/FourSeven.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index b5aba5cb83..b11c80fc57 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -157,6 +157,12 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base * @return bool */ public function migrateSettings(CRM_Queue_TaskContext $ctx) { + // Tip: If there are problems with adding the new uniqueness index, try inspecting: + // SELECT name, domain_id, contact_id, count(*) AS dupes FROM civicrm_setting cs GROUP BY name, domain_id, contact_id HAVING dupes > 1; + + // Nav records are expendable. https://forum.civicrm.org/index.php?topic=36933.0 + CRM_Core_DAO::executeQuery('DELETE FROM civicrm_setting WHERE contact_id IS NOT NULL AND name = "navigation"'); + CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_setting DROP INDEX index_group_name'); CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_setting DROP COLUMN group_name'); CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_setting ADD UNIQUE INDEX index_domain_contact_name (domain_id, contact_id, name)'); -- 2.25.1