Skip to content
Snippets Groups Projects
Unverified Commit 03f3525d authored by colemanw's avatar colemanw Committed by GitHub
Browse files

Merge pull request #19934 from eileenmcnaughton/recur

#2487 Update defaults for civicrm_contribution_recur table
parents b524b414 d462cb53
Branches
Tags
No related merge requests found
......@@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Contribute/ContributionRecur.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:f84af6c77cc1e2d93f27952a2a9766fd)
* (GenCodeChecksum:47f389ccf532868b1a41d77c7691912a)
*/
/**
......@@ -385,6 +385,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
'description' => ts('Number of time units for recurrence of payment.'),
'required' => TRUE,
'where' => 'civicrm_contribution_recur.frequency_interval',
'default' => '1',
'table_name' => 'civicrm_contribution_recur',
'entity' => 'ContributionRecur',
'bao' => 'CRM_Contribute_BAO_ContributionRecur',
......@@ -416,6 +417,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
'description' => ts('The date the first scheduled recurring contribution occurs.'),
'required' => TRUE,
'where' => 'civicrm_contribution_recur.start_date',
'default' => 'CURRENT_TIMESTAMP',
'table_name' => 'civicrm_contribution_recur',
'entity' => 'ContributionRecur',
'bao' => 'CRM_Contribute_BAO_ContributionRecur',
......@@ -434,6 +436,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
'description' => ts('When this recurring contribution record was created.'),
'required' => TRUE,
'where' => 'civicrm_contribution_recur.create_date',
'default' => 'CURRENT_TIMESTAMP',
'table_name' => 'civicrm_contribution_recur',
'entity' => 'ContributionRecur',
'bao' => 'CRM_Contribute_BAO_ContributionRecur',
......@@ -451,6 +454,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
'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',
'table_name' => 'civicrm_contribution_recur',
'entity' => 'ContributionRecur',
'bao' => 'CRM_Contribute_BAO_ContributionRecur',
......@@ -587,7 +591,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
'import' => TRUE,
'where' => 'civicrm_contribution_recur.contribution_status_id',
'export' => TRUE,
'default' => '1',
'default' => '2',
'table_name' => 'civicrm_contribution_recur',
'entity' => 'ContributionRecur',
'bao' => 'CRM_Contribute_BAO_ContributionRecur',
......
......@@ -71,8 +71,8 @@ class CRM_Upgrade_Incremental_php_FiveThirtySeven extends CRM_Upgrade_Incrementa
'civicrm_note', 'note_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Date attached to the note'");
$this->addTask('core-issue#2243 - Add created_date to civicrm_note', 'addColumn',
'civicrm_note', 'created_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the note was created'");
$this->addTask('core-issue#2243 - Update existing note_date and created_date', 'updateNoteDates');
$this->addTask('core-issue#2487 Add / alter defaults for civicrm_contribution_recur', 'updateDBDefaultsForContributionRecur');
}
// /**
......@@ -110,4 +110,33 @@ class CRM_Upgrade_Incremental_php_FiveThirtySeven extends CRM_Upgrade_Incrementa
return TRUE;
}
/**
* Update DB defaults for contribution recur.
*
* This adds default values for start_date, create_date, modified_date
* and frequency_interval in line with what is in the UI (frequency_unit
* already has 'month' as the default.
*
* The default of 'Pending' for contribution_recur_id will be updated as
* appropriate as soon as a contribution is attached to it by BAO code.
*
* The core code does not rely on the defaults for any of these fields.
*
* @param \CRM_Queue_TaskContext $ctx
*
* @return bool
*/
public static function updateDBDefaultsForContributionRecur(CRM_Queue_TaskContext $ctx): bool {
$pendingID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionRecur', 'contribution_status_id', 'Pending');
CRM_Core_DAO::executeQuery("
ALTER TABLE `civicrm_contribution_recur`
MODIFY COLUMN `start_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'The date the first scheduled recurring contribution occurs.',
MODIFY COLUMN `create_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When this recurring contribution record was created.',
MODIFY COLUMN `modified_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Last updated date for this record. mostly the last time a payment was received',
MODIFY COLUMN `contribution_status_id` int(10) unsigned DEFAULT {$pendingID},
MODIFY COLUMN `frequency_interval` int(10) unsigned NOT NULL DEFAULT 1 COMMENT 'Number of time units for recurrence of payment.';
");
return TRUE;
}
}
......@@ -93,6 +93,7 @@
<title>Interval (number of units)</title>
<type>int unsigned</type>
<required>true</required>
<default>1</default>
<comment>Number of time units for recurrence of payment.</comment>
<add>1.6</add>
<html>
......@@ -114,6 +115,7 @@
<title>Start Date</title>
<type>datetime</type>
<required>true</required>
<default>CURRENT_TIMESTAMP</default>
<comment>The date the first scheduled recurring contribution occurs.</comment>
<add>1.6</add>
<html>
......@@ -128,6 +130,7 @@
<title>Created Date</title>
<type>datetime</type>
<required>true</required>
<default>CURRENT_TIMESTAMP</default>
<comment>When this recurring contribution record was created.</comment>
<add>1.6</add>
<html>
......@@ -141,6 +144,7 @@
<name>modified_date</name>
<title>Modified Date</title>
<type>datetime</type>
<default>CURRENT_TIMESTAMP</default>
<comment>Last updated date for this record. mostly the last time a payment was received</comment>
<add>1.6</add>
<html>
......@@ -259,7 +263,7 @@
<uniqueName>contribution_recur_contribution_status_id</uniqueName>
<title>Status</title>
<type>int unsigned</type>
<default>1</default>
<default>2</default>
<import>true</import>
<add>1.6</add>
<pseudoconstant>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment