From 8e2e96a5d78e034ca0c540fb194d6f98739cd404 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Wed, 20 Jul 2016 13:03:09 +0530 Subject: [PATCH] CRM-19100: 4.7.8 SQL Incremental Update May Fail for UTF8 --- CRM/Upgrade/Incremental/php/FourSeven.php | 16 ++++++++++++++++ CRM/Upgrade/Incremental/sql/4.7.8.mysql.tpl | 3 --- xml/schema/Contact/Contact.xml | 3 +-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index ab9fee7780..5ff88e08e5 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -218,6 +218,7 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base public function upgrade_4_7_10($rev) { $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); $this->addTask(ts('Upgrade Add Help Pre and Post Fields to price value table'), 'addHelpPreAndHelpPostFieldsPriceFieldValue'); + $this->addTask(ts('Alter index and type for image URL'), 'alterIndexAndTypeForImageURL'); } /* @@ -726,4 +727,19 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_ return TRUE; } + /** + * CRM-19100 - Alter Index and Type for Image URL + * @return bool + */ + public static function alterIndexAndTypeForImageURL() { + $dao = CRM_Core_DAO::executeQuery("SHOW INDEX FROM civicrm_contact WHERE KEY_NAME = 'index_image_url'"); + if ($dao->N) { + CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_contact` DROP INDEX `index_image_url`"); + } + CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_contact` CHANGE `image_URL` `image_URL` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'optional URL for preferred image (photo, logo, etc.) to display for this contact.'"); + CRM_Core_DAO::executeQuery("CREATE INDEX `index_image_url` ON `civicrm_contact` ( image_URL(128) )"); + + return TRUE; + } + } diff --git a/CRM/Upgrade/Incremental/sql/4.7.8.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.7.8.mysql.tpl index 5c1cfb611b..a7fca7aced 100644 --- a/CRM/Upgrade/Incremental/sql/4.7.8.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.7.8.mysql.tpl @@ -1,8 +1,5 @@ {* file to handle db changes in 4.7.8 during upgrade *} -#CRM-17967 - Allow conact image file name length during upload up to 255 characters long -ALTER TABLE `civicrm_contact` CHANGE `image_URL` `image_URL` VARCHAR(512) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'optional URL for preferred image (photo, logo, etc.) to display for this contact.'; - -- CRM-18516 Convert the date fields relating to group caching and acl caching timestamp ALTER TABLE civicrm_group CHANGE cache_date cache_date timestamp NULL DEFAULT NULL , CHANGE refresh_date refresh_date timestamp NULL DEFAULT NULL; ALTER TABLE civicrm_acl_cache CHANGE modified_date modified_date timestamp NULL DEFAULT NULL; diff --git a/xml/schema/Contact/Contact.xml b/xml/schema/Contact/Contact.xml index e6ffe418ad..8cfc7b76aa 100644 --- a/xml/schema/Contact/Contact.xml +++ b/xml/schema/Contact/Contact.xml @@ -264,8 +264,7 @@ image_URL - varchar - 512 + text true optional URL for preferred image (photo, logo, etc.) to display for this contact. 1.1 -- 2.25.1