Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-20892 Fix up issue where created_date may not have yet been conve… #11211

Merged
merged 1 commit into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CRM/Upgrade/Incremental/php/FourSeven.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'");
Expand Down Expand Up @@ -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;
}

}
3 changes: 0 additions & 3 deletions CRM/Upgrade/Incremental/sql/4.7.27.mysql.tpl
Original file line number Diff line number Diff line change
@@ -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.';