Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-2917

Upgrade does not deal with is_primary for address/email/phone/im properly

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:
      None

      Description

      If a contact has multiple email addresses (in different locations) in v1.9, those email addresses would be marked primary

      In v2.0 and later the contact can have only ONE primary email/address/phone/im irrespective of location type.

      We need to ensure that upgrade cleans up the is_primary values. Ideally it should keep is_primary on the email / phone etc of the primary location type for the contact and reset the others to 0

      Not doing so, causes duplicate lines in export. Check: http://forum.civicrm.org/index.php/topic,2861.msg12530.html#msg12530 for one instance

      The sql to find all contact_ids in a table that have this issue is:

      select contact_id, count(id) as cnt
      from civicrm_email
      where is_primary = 1 group by contact_id having cnt > 1;

      We also need a standalone script for folks who have already upgraded.

      To keep things consistent between standalone and upgrade script, we can use the "lowest id" rule and keep the lowest record with is_primary as the primary one and reset the rest.

      We should also minimize the number of update queries, so maybe do:

      UPDATE civicirm_email SET is_primary = 0 where contact_id IN ( 256 contact ids or so here )

        Attachments

          Activity

            People

            • Assignee:
              kurund Kurund Jalmi
              Reporter:
              lobo Donald A. Lobo
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: