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

Change subject: Update for primaries not set.
......................................................................


Update for primaries not set.

Bug: T143062
Change-Id: I863d09ea41fc2768901624ba3c0693c6106ac4c0
---
M sites/all/modules/wmf_civicrm/wmf_civicrm.install
1 file changed, 25 insertions(+), 0 deletions(-)

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



diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.install 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.install
index 1d84e5b..9aeb973 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.install
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.install
@@ -2188,3 +2188,28 @@
   civicrm_initialize();
   CRM_Core_DAO::executeQuery("DELETE FROM civicrm_email WHERE email = 
'nob...@wikimedia.org'");
 }
+
+/**
+ * Fix contacts who have no primary - this has arisen from the dedupes.
+ *
+ * I'll probably run this again once I've fixed dedupe to stop creating them
+ * but this fixes the ~10000 contacts who currently don't have an address 
marked as primary.
+ *
+ * Staging : (9 min 16.83 sec)
+ *
+ * Bug: T143062
+ */
+function wmf_civicrm_update_7250() {
+  civicrm_initialize();
+  CRM_Core_DAO::executeQuery("
+    UPDATE civicrm_email SET is_primary = 1
+    WHERE id IN (SELECT id FROM
+      (
+        SELECT contact_id, sum(is_primary) as c, e.id
+        FROM civicrm_email e
+        INNER JOIN civicrm_contact c ON c.id = contact_id AND is_deleted = 0
+        GROUP BY contact_id HAVING c = 0
+      ) as i
+    )
+  ");
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I863d09ea41fc2768901624ba3c0693c6106ac4c0
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: deployment
Gerrit-Owner: Eileen <emcnaugh...@wikimedia.org>
Gerrit-Reviewer: Awight <awi...@wikimedia.org>
Gerrit-Reviewer: Cdentinger <cdentin...@wikimedia.org>
Gerrit-Reviewer: Eileen <emcnaugh...@wikimedia.org>
Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to