From d0e7e12479b1ae08a299092b4623653d33c779c2 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 21 Jul 2016 10:20:44 +1000 Subject: [PATCH] Shift Upgrade code to php for more stability --- CRM/Upgrade/Incremental/php/FourSeven.php | 14 ++++++++++++++ CRM/Upgrade/Incremental/sql/4.7.10.mysql.tpl | 7 ------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index 9d820e8a0b..ce2c191223 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -225,6 +225,7 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base $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'); + $this->addTask(ts('Add Data Type column to civicrm_option_group'), 'addDataTypeColumnToOptionGroupTable'); } /** @@ -828,4 +829,17 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_ return TRUE; } + /** + * CRM-18651 Add DataType column to Option Group Table + * @return bool + */ + public static function addDataTypeColumnToOptionGroupTable() { + if (!CRM_Core_BAO_SchemaHandler::checkIfFieldExists('civicrm_option_group', 'data_type') { + CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_option_group` ADD COLUMN `data_type` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL comment 'Data Type of Option Group.'"); + } + CRM_Core_DAO::executeQuery("UPDATE `civicrm_option_group` SET `data_type` = 'Integer' + WHERE name IN ('activity_type', 'gender', 'payment_instrument', 'participant_role', 'event_type')"); + return TRUE; + } + } diff --git a/CRM/Upgrade/Incremental/sql/4.7.10.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.7.10.mysql.tpl index a08076a12d..52e04cca5f 100644 --- a/CRM/Upgrade/Incremental/sql/4.7.10.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.7.10.mysql.tpl @@ -21,10 +21,3 @@ INSERT INTO `civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `is_optgroup`, `is_reserved`, `is_active`) VALUES (@option_group_id_ext, {localize}'{ts escape="sql"}odt{/ts}'{/localize}, @option_group_id_ext_val+1, 'odt', NULL, 0, 0, @option_group_id_ext_wt+1, 0, 1, 1); - ---CRM-18651 Add in Data Type colum to option group table and set for some option groups -ALTER TABLE civicrm_option_group -ADD `data_type` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Data Type of Option Group.'; -UPDATE civicrm_option_group SET `data_type` = 'Integer' -WHERE name in ('activity_type', 'gender', 'payment_instrument', 'participant_role', 'event_type', - 'activity_status',); -- 2.25.1