Ejegg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/303608

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, 20 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/08/303608/1

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..411c08d
--- /dev/null
+++ b/sites/all/modules/wmf_civicrm/scripts/fix_recur_currency.sql
@@ -0,0 +1,20 @@
+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_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: newchange
Gerrit-Change-Id: If9080c5cb78d2541ac12e5b0ee8e267201b30d43
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>

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

Reply via email to