Use mysql to set mailing.created_date
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 17 Jun 2021 02:04:11 +0000 (14:04 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 17 Jun 2021 05:43:41 +0000 (17:43 +1200)
On digging I determined this trigger hokiness was all about mysql
5.5 and we can ditch it now

https://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-5.html#mysqld-5-6-5-data-types

and https://github.com/civicrm/civicrm-core/pull/10953#issuecomment-327613771

Note that we still support mysql 5.6 and the current version is 5.6.51

I think it's fine to require that the 5.6 minimum is 5.6.5 as released in 2012

I'll do the upgrade script as a follow up

CRM/Mailing/DAO/Mailing.php
CRM/Upgrade/Incremental/sql/5.40.alpha1.mysql.tpl
Civi/Core/Container.php
xml/schema/Mailing/Mailing.xml

index 24666f8b5894910958fffbfee0a711c3f269b91f..1ca7c178abae56526a9dde409d7b30ec871b2de7 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Mailing/Mailing.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:a2d71da677efc3436ae8ed9414cdecca)
+ * (GenCodeChecksum:4c28acf96d01fa990a3af7f2d72344b5)
  */
 
 /**
@@ -844,7 +844,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'description' => ts('Date and time this mailing was created.'),
           'required' => FALSE,
           'where' => 'civicrm_mailing.created_date',
-          'default' => 'NULL',
+          'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
index 6a2df9741d2283f754ac8cef8ed4ec239d92a98e..3841afccc594e41e17b94fbcf0fe201fac641aad 100644 (file)
@@ -10,3 +10,6 @@ UPDATE civicrm_option_value SET name = 'Case'
   WHERE value = 'civicrm_case' AND option_group_id = @option_group_id_tuf;
 UPDATE civicrm_option_value SET name = 'File'
   WHERE value = 'civicrm_file' AND option_group_id = @option_group_id_tuf;
+
+ALTER TABLE civicrm_mailing
+MODIFY COLUMN `created_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Date and time this mailing was created.';
index 0632c649c440e3adcb8b1fc81aabd835f49d7033..72e69c4762d11702877d06615f43156eb48aec0e 100644 (file)
@@ -285,11 +285,6 @@ class Container {
     $container->setDefinition('cache_config', new Definition('ArrayObject'))
       ->setFactory([new Reference(self::SELF), 'createCacheConfig'])->setPublic(TRUE);
 
-    $container->setDefinition('civi.mailing.triggers', new Definition(
-      'Civi\Core\SqlTrigger\TimestampTriggers',
-      ['civicrm_mailing', 'Mailing']
-    ))->addTag('kernel.event_listener', ['event' => 'hook_civicrm_triggerInfo', 'method' => 'onTriggerInfo'])->setPublic(TRUE);
-
     $container->setDefinition('civi.activity.triggers', new Definition(
       'Civi\Core\SqlTrigger\TimestampTriggers',
       ['civicrm_activity', 'Activity']
index ca0dee584aa6b57cdcc2b514eae4ce454bea2777..c5e65fe046cd4e3f41b0e562f30e59d99bbc3474 100644 (file)
   <field>
     <name>created_date</name>
     <type>timestamp</type>
-    <default>NULL</default>
+    <default>CURRENT_TIMESTAMP</default>
     <required>false</required>
     <title>Mailing Created Date</title>
     <comment>Date and time this mailing was created.</comment>