jenkins-bot has submitted this change and it was merged.

Change subject: Fix incorrect contribution_recur rows
......................................................................


Fix incorrect contribution_recur rows

This should get just the rows that were damaged by the currency
clobbering bug.

Bug: T142312
Change-Id: If9080c5cb78d2541ac12e5b0ee8e267201b30d43
---
A sites/all/modules/wmf_civicrm/scripts/fix_recur_currency.sql
1 file changed, 21 insertions(+), 0 deletions(-)

Approvals:
  XenoRyet: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/sites/all/modules/wmf_civicrm/scripts/fix_recur_currency.sql 
b/sites/all/modules/wmf_civicrm/scripts/fix_recur_currency.sql
new file mode 100644
index 0000000..4674b02
--- /dev/null
+++ b/sites/all/modules/wmf_civicrm/scripts/fix_recur_currency.sql
@@ -0,0 +1,21 @@
+CREATE TEMPORARY TABLE fix_recur (
+  id int(10) unsigned PRIMARY KEY,
+  currency varchar(3)
+);
+
+INSERT INTO fix_recur
+SELECT cr.id, lcr.currency
+FROM civicrm_contribution_recur cr
+INNER JOIN log_civicrm_contribution_recur lcr ON cr.id = lcr.id
+  AND lcr.currency <> cr.currency
+  AND lcr.log_conn_id NOT LIKE 'c_%'
+  AND lcr.log_user_id IS NULL
+  AND lcr.log_date > '2016-05-01'
+  AND cr.modified_date > '2016-05-01'
+  AND cr.currency = 'USD'
+GROUP BY cr.id, lcr.currency;
+
+UPDATE civicrm_contribution_recur cr
+INNER JOIN fix_recur f on cr.id = f.id
+SET cr.currency = f.currency;
+

-- 
To view, visit https://gerrit.wikimedia.org/r/303608
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If9080c5cb78d2541ac12e5b0ee8e267201b30d43
Gerrit-PatchSet: 2
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: Springle <[email protected]>
Gerrit-Reviewer: XenoRyet <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to