1

[Error: Upgrade DB to 4.7.18: SQL] [nativecode=1062 ** Duplicate entry 'Chandigarh-1101' for key 'UI_name_country_id']

How can I fix the error as given below:

INSERT INTO `civicrm_state_province` (`id`, `country_id`, `abbreviation`, `name`) VALUES (NULL, 1101, "CH", "Chandigarh"), (NULL, 1083, "CP", "Central"), (NULL, 1083, "EP", "Eastern"), (NULL, 1083, "NP", "Northern"), (NULL, 1083, "WP", "Western"), (NULL, 1181, "K", "Saint Kitts"), (NULL, 1181, "N", "Nevis"), (NULL, 1190, "E", "Eastern"), (NULL, 1190, "N", "Northern"), (NULL, 1190, "S", "Southern") [nativecode=1062 ** Duplicate entry 'Chandigarh-1101' for key 'UI_name_country_id']
DebugInfo   INSERT INTO `civicrm_state_province` (`id`, `country_id`, `abbreviation`, `name`) VALUES (NULL, 1101, "CH", "Chandigarh"), (NULL, 1083, "CP", "Central"), (NULL, 1083, "EP", "Eastern"), (NULL, 1083, "NP", "Northern"), (NULL, 1083, "WP", "Western"), (NULL, 1181, "K", "Saint Kitts"), (NULL, 1181, "N", "Nevis"), (NULL, 1190, "E", "Eastern"), (NULL, 1190, "N", "Northern"), (NULL, 1190, "S", "Southern") [nativecode=1062 ** Duplicate entry 'Chandigarh-1101' for key 'UI_name_country_id']

enter image description here

1

The upgrade for 4.7.18 tries to insert new state in civicrm_state_province table. This was done via https://issues.civicrm.org/jira/browse/CRM-19993.

But seems you already have Chandigarh in the table due to which mysql finds a duplicate row already present in the database and eventually displays an error. So the question is how this record is already present in your database?

  • Have you tried this upgrade for 4.7.18 before and retrying this again? If yes, try getting a backup of the previous version and then start the upgrade process.
  • Have you added the new state Chandigarh in your DB manually in your previous version? In this case, you can simply delete the Chandigarh entry manually from civicrm_state_province table and restart the upgrade. It will create the entry for Chandigarh so you'll not lose any state record from your DB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.