CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Update on solving Key Contraint violations ( hardcoded location_type_id values)
Pages: [1]

Author Topic: Update on solving Key Contraint violations ( hardcoded location_type_id values)  (Read 576 times)

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Update on solving Key Contraint violations ( hardcoded location_type_id values)
June 17, 2011, 11:03:46 am
On incremental upgrades we have a series of key constraint violation errors that fatally undermine the upgrades. Here's why and an update on the dirty fixes. Thanks are due to earlier posters

See http://forum.civicrm.org/index.php/topic,14884.0.html for one of the first posts I know of.

On our installation the civicrm_location_type table entries are not standard. For some reason Home has id=6; Work has id=7. Main is id=8 - In a standard installation this would be 1, 2 and 3 respectively.

I've never quite managed to work out how to change all the FK references at once so that I can reset the id's of this field.

The consequence of this is that incremental upgrades often fail due to FK contraint violations.

I get round this by hacking some of the upgrade scripts in the directory  sites/all/modules/civicrm/CRM/Upgrade/Incremental/sql

To date the templates that need to be hacked are:

3.2.beta3.mysql.tpl
3.2.beta4.mysql.tpl
3.3.alpha1.mysql.tpl
3.4.3.mysql.tpl

The first three hard code the reference to home and work phone numbers (the two betas) and home addresses (3.3.alpha1) so changes are simple - in my case I change the values passed into the location_type_id from 1 and 2 to 6 and 7 - and hey presto.

3.4.3 is different - It is passing values of the main phone number, email address and so on - standard installations use id=3, our happens to use 8... Dunno about yours of course!

Hope it helps someone, although I feel guilty that I have not worked out how to change the script so that it looks up the correct values rather than hardcoding them.

I can't get my head around that

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Update on solving Key Contraint violations ( hardcoded location_type_id values)
June 17, 2011, 11:38:15 am
Thanks for the detailed post. We have already filed an issue to fix this http://issues.civicrm.org/jira/browse/CRM-8318

It will be part of next release.

Thanks
Kurund
Found this reply helpful? Support CiviCRM

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Update on solving Key Contraint violations ( hardcoded location_type_id values)

This forum was archived on 2017-11-26.