-
-
Notifications
You must be signed in to change notification settings - Fork 827
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
dev/core#2487 Update defaults for civicrm_contribution_recur table #19934
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,8 +67,8 @@ public function upgrade_5_37_alpha1($rev) { | |
'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'); | ||
} | ||
|
||
// /** | ||
|
@@ -106,4 +106,33 @@ public static function alterSavedSearchFK(CRM_Queue_TaskContext $ctx) { | |
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.', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should these date columns be datetime or timestamps? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @seamuslee001 I tested & the default works with datetime - which is what they already are. I wanted to leave any type change out of scope There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I too prefer to have separate PR/issue for changing default value compared to changing the type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JoeMurray I did have the PR for that change (linked above) - I closed it to incorporate into this as I felt it had been canvassed & upgrade scripts don't play well as separate PRs |
||
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; | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be nice to have comment
// ie Pending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree it would be nice, but we can't put comments in a generated DAO file.