From 96c2bbadd385de97c3c4e6d0a4e042425d934f98 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 30 Oct 2017 08:15:10 +1100 Subject: [PATCH] CRM-20892 Fix up issue where created_date may not have yet been converted to timestamp so should stay as datetime in upgrade --- CRM/Upgrade/Incremental/php/FourSeven.php | 14 ++++++++++++++ CRM/Upgrade/Incremental/sql/4.7.27.mysql.tpl | 3 --- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index d1bc87ba8b..d51e716e5d 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -447,6 +447,7 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base */ public function upgrade_4_7_27($rev) { $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); + $this->addTask('CRM-20892 Change created_date to default to NULL', 'civiMailingCreatedDateNull'); $this->addTask('CRM-21234 Missing subdivisions of Tajikistan', 'tajikistanMissingSubdivisions'); $this->addTask('CRM-20892 - Add modified_date to civicrm_mailing', 'addColumn', 'civicrm_mailing', 'modified_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When the mailing (or closely related entity) was created or modified or deleted.'"); @@ -1310,4 +1311,17 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_ return $config->imageUploadDir && $config->imageUploadURL && $check->isDirAccessible($config->imageUploadDir, $config->imageUploadURL); } + /** + * CRM-20892 Convert default of created_date in civicrm_mailing table to NULL + * @return bool + */ + public static function civiMailingCreatedDateNull(CRM_Queue_TaskContext $ctx) { + $dataType = 'timestamp'; + if (CRM_Utils_Check_Component_Timestamps::isFieldType('civicrm_mailing', 'created_date', 'datetime')) { + $dataType = 'datetime'; + } + CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_mailing CHANGE created_date created_date {$dataType} NULL DEFAULT NULL COMMENT 'Date and time this mailing was created.'"); + return TRUE; + } + } diff --git a/CRM/Upgrade/Incremental/sql/4.7.27.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.7.27.mysql.tpl index 749a947a17..a971b26276 100644 --- a/CRM/Upgrade/Incremental/sql/4.7.27.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.7.27.mysql.tpl @@ -1,4 +1 @@ {* file to handle db changes in 4.7.27 during upgrade *} - --- CRM-20892 Change created_date default so that we can add a modified_date column -ALTER TABLE civicrm_mailing CHANGE created_date created_date timestamp NULL DEFAULT NULL COMMENT 'Date and time this mailing was created.'; -- 2.25.1