Skip to content

Commit

Permalink
CRM-20892 Convert Created_date to default NULL and add in trigger to …
Browse files Browse the repository at this point in the history
…set it

Remove duplicate was
  • Loading branch information
seamuslee001 committed Sep 10, 2017
1 parent 5e7688e commit 83934fd
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 34 deletions.
6 changes: 3 additions & 3 deletions CRM/Mailing/DAO/Mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
* Generated from xml/schema/CRM/Mailing/Mailing.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:7f90165e5c470ceb7e4644a5ab0660d1)
* (GenCodeChecksum:4b11c9e5728b8468467a00efeff9c865)
*/
require_once 'CRM/Core/DAO.php';
require_once 'CRM/Utils/Type.php';
Expand Down Expand Up @@ -679,7 +679,7 @@ static function &fields() {
'title' => ts('Mailing Created Date') ,
'description' => 'Date and time this mailing was created.',
'required' => false,
'default' => 'CURRENT_TIMESTAMP',
'default' => 'NULL',
'table_name' => 'civicrm_mailing',
'entity' => 'Mailing',
'bao' => 'CRM_Mailing_BAO_Mailing',
Expand Down Expand Up @@ -918,7 +918,7 @@ static function &fields() {
'name' => 'modified_date',
'type' => CRM_Utils_Type::T_TIMESTAMP,
'title' => ts('Modified Date') ,
'description' => 'When was the mailing (or closely related entity) was created or modified or deleted.',
'description' => 'When the mailing (or closely related entity) was created or modified or deleted.',
'required' => false,
'export' => true,
'where' => 'civicrm_mailing.modified_date',
Expand Down
4 changes: 2 additions & 2 deletions CRM/Upgrade/Incremental/php/FourSeven.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,9 @@ public function upgrade_4_7_25($rev) {
* @param string $rev
*/
public function upgrade_4_7_26($rev) {
$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 was the mailing (or closely related entity) was created or modified or deleted.'");
$this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
$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
3 changes: 3 additions & 0 deletions CRM/Upgrade/Incremental/sql/4.7.26.mysql.tpl
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{* file to handle db changes in 4.7.26 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.';
5 changes: 5 additions & 0 deletions Civi/Core/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ public function createContainer() {
->setFactory(array($class, 'singleton'));
}

$container->setDefinition('civi.mailing.triggers', new Definition(
'Civi\Core\SqlTrigger\TimestampTriggers',
array('civicrm_mailing', 'Mailing')
))->addTag('kernel.event_listener', array('event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo'));

$container->setDefinition('civi.activity.triggers', new Definition(
'Civi\Core\SqlTrigger\TimestampTriggers',
array('civicrm_activity', 'Activity')
Expand Down
54 changes: 27 additions & 27 deletions sql/civicrm_generated.mysql

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions xml/schema/Mailing/Mailing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
<field>
<name>created_date</name>
<type>timestamp</type>
<default>CURRENT_TIMESTAMP</default>
<default>NULL</default>
<required>false</required>
<title>Mailing Created Date</title>
<comment>Date and time this mailing was created.</comment>
Expand Down Expand Up @@ -491,7 +491,7 @@
<name>modified_date</name>
<uniqueName>mailing_modified_date</uniqueName>
<type>timestamp</type>
<comment>When was the mailing (or closely related entity) was created or modified or deleted.</comment>
<comment>When the mailing (or closely related entity) was created or modified or deleted.</comment>
<required>false</required>
<export>true</export>
<default>CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP</default>
Expand Down

0 comments on commit 83934fd

Please sign in to comment.