[MediaWiki-commits] [Gerrit] wikimedia...crm[deployment]: Revise update to primaries not set.

2016-09-21 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Revise update to primaries not set.
..


Revise update to primaries not set.

This worked on staging but it must be missing some triggers as it failed on a 
circularity on prod.

The temporary table should get past that

After running this on staging I compared the total number of non-primary emails 
on staging with live.

MariaDB [dev_civicrm]> SELECT count(*) FROM civicrm_email WHERE is_primary = 0;
+--+
| count(*) |
+--+
|   103604 |
+--+
1 row in set (0.41 sec)

MariaDB [dev_civicrm]> SELECT count(*) FROM civicrm.civicrm_email WHERE 
is_primary = 0;
+--+
| count(*) |
+--+
|83426 |

Around 20,000 difference - more than just the update but the DBs were not in 
like state to start with and I was really worried about
something much larger happening (like updating all of them to be primary)

The update would be around 10 k

Bug: T143062
Change-Id: I73ecc0da3b89ea45db3cd4a1f6841ad850369d36
---
M sites/all/modules/wmf_civicrm/wmf_civicrm.install
1 file changed, 7 insertions(+), 3 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 9aeb973..78b227f 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.install
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.install
@@ -2202,14 +2202,18 @@
 function wmf_civicrm_update_7250() {
   civicrm_initialize();
   CRM_Core_DAO::executeQuery("
-UPDATE civicrm_email SET is_primary = 1
-WHERE id IN (SELECT id FROM
+CREATE TEMPORARY TABLE civicrm_email_updates
+ 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
-)
+  ");
+
+  CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_email_updates ADD INDEX 
index_id(id)");
+  CRM_Core_DAO::executeQuery("UPDATE civicrm_email e INNER JOIN 
civicrm_email_updates u ON e.id = u.id
+SET e.is_primary = 1
   ");
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I73ecc0da3b89ea45db3cd4a1f6841ad850369d36
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: deployment
Gerrit-Owner: Eileen 
Gerrit-Reviewer: Awight 
Gerrit-Reviewer: Cdentinger 
Gerrit-Reviewer: Eileen 
Gerrit-Reviewer: Ejegg 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] wikimedia...crm[deployment]: Revise update to primaries not set.

2016-09-21 Thread Eileen (Code Review)
Eileen has uploaded a new change for review.

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

Change subject: Revise update to primaries not set.
..

Revise update to primaries not set.

This worked on staging but it must be missing some triggers as it failed on a 
circularity on prod.

The temporary table should get past that

After running this on staging I compared the total number of non-primary emails 
on staging with live.

MariaDB [dev_civicrm]> SELECT count(*) FROM civicrm_email WHERE is_primary = 0;
+--+
| count(*) |
+--+
|   103604 |
+--+
1 row in set (0.41 sec)

MariaDB [dev_civicrm]> SELECT count(*) FROM civicrm.civicrm_email WHERE 
is_primary = 0;
+--+
| count(*) |
+--+
|83426 |

Around 20,000 difference - more than just the update but the DBs were not in 
like state to start with and I was really worried about
something much larger happening (like updating all of them to be primary)

The update would be around 10 k

Bug: T143062
Change-Id: I73ecc0da3b89ea45db3cd4a1f6841ad850369d36
---
M sites/all/modules/wmf_civicrm/wmf_civicrm.install
1 file changed, 7 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm 
refs/changes/54/312154/1

diff --git a/sites/all/modules/wmf_civicrm/wmf_civicrm.install 
b/sites/all/modules/wmf_civicrm/wmf_civicrm.install
index 9aeb973..78b227f 100644
--- a/sites/all/modules/wmf_civicrm/wmf_civicrm.install
+++ b/sites/all/modules/wmf_civicrm/wmf_civicrm.install
@@ -2202,14 +2202,18 @@
 function wmf_civicrm_update_7250() {
   civicrm_initialize();
   CRM_Core_DAO::executeQuery("
-UPDATE civicrm_email SET is_primary = 1
-WHERE id IN (SELECT id FROM
+CREATE TEMPORARY TABLE civicrm_email_updates
+ 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
-)
+  ");
+
+  CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_email_updates ADD INDEX 
index_id(id)");
+  CRM_Core_DAO::executeQuery("UPDATE civicrm_email e INNER JOIN 
civicrm_email_updates u ON e.id = u.id
+SET e.is_primary = 1
   ");
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I73ecc0da3b89ea45db3cd4a1f6841ad850369d36
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: deployment
Gerrit-Owner: Eileen 

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