diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index d1bc87ba8b7f..d51e716e5d7f 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -447,6 +447,7 @@ public function upgrade_4_7_25($rev) { */ 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 @@ protected function checkImageUploadDir() { 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 749a947a170c..a971b26276be 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.';