ContributionRecur modified_date should update to current_timestamp on update
authorMatthew Wire <mjw@mjwconsult.co.uk>
Tue, 14 Sep 2021 15:22:11 +0000 (16:22 +0100)
committerMatthew Wire <mjw@mjwconsult.co.uk>
Wed, 29 Sep 2021 12:05:31 +0000 (13:05 +0100)
CRM/Contribute/DAO/ContributionRecur.php
CRM/Upgrade/Incremental/sql/5.43.alpha1.mysql.tpl
tests/phpunit/api/v3/SyntaxConformanceTest.php
xml/schema/Contribute/ContributionRecur.xml

index 4913ac61c71793ef766945114b55bb9baa0a34c9..a1ebe04336bef2bc18c89a359379ec9f2d6d900f 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Contribute/ContributionRecur.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:6c94785d608dc72c00b663ee8ad4e180)
+ * (GenCodeChecksum:5f08744178821ce074d21fe4cdddbdaa)
  */
 
 /**
@@ -97,7 +97,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
   /**
    * Last updated date for this record. mostly the last time a payment was received
    *
-   * @var datetime
+   * @var timestamp
    */
   public $modified_date;
 
@@ -450,11 +450,11 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
         ],
         'contribution_recur_modified_date' => [
           'name' => 'modified_date',
-          'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
+          'type' => CRM_Utils_Type::T_TIMESTAMP,
           'title' => ts('Modified Date'),
           'description' => ts('Last updated date for this record. mostly the last time a payment was received'),
           'where' => 'civicrm_contribution_recur.modified_date',
-          'default' => 'CURRENT_TIMESTAMP',
+          'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
index 0447e9d2b75922aed3dabffe75580722428ad577..943d62201f23158ecd36b77fc96c1c68d3333f35 100644 (file)
@@ -2,3 +2,6 @@
 UPDATE civicrm_msg_template SET is_reserved = 0 WHERE is_reserved IS NULL;
 ALTER TABLE civicrm_msg_template
 MODIFY COLUMN `is_reserved` tinyint(4) DEFAULT 0 COMMENT 'is this the reserved message template which we ship for the workflow referenced by workflow_id?';
+
+{* https://github.com/civicrm/civicrm-core/pull/21472 *}
+ALTER TABLE civicrm_contribution_recur MODIFY COLUMN modified_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Last updated date for this record. mostly the last time a payment was received';
index b9d496bb9480c41b7618046cbe6d548bbf40f9c7..9acb59823c72f13c3ebff9ff0bcd2ee2088ce8bf 100644 (file)
@@ -654,6 +654,11 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
           'definition',
         ],
       ],
+      'ContributionRecur' => [
+        'break_return' => [
+          'contribution_recur_modified_date',
+        ],
+      ],
       'Domain' => ['cant_update' => ['domain_version']],
       'MembershipBlock' => [
         'cant_update' => [
index bc8e0eafe02193c101e3c9e9e280005c7c220647..10ccc535920a9ecb613fd846e3db759e52c1add4 100644 (file)
   <field>
     <name>modified_date</name>
     <title>Modified Date</title>
-    <type>datetime</type>
-    <default>CURRENT_TIMESTAMP</default>
+    <type>timestamp</type>
+    <default>CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP</default>
     <comment>Last updated date for this record. mostly the last time a payment was received</comment>
     <add>1.6</add>
     <html>