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) »
  • Error upgrading from 3.4.2 to 3.4.3
Pages: [1]

Author Topic: Error upgrading from 3.4.2 to 3.4.3  (Read 1447 times)

Chelcone

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 1
  • CiviCRM version: 3.4.0
  • CMS version: Drupal 6.*
  • MySQL version: MySQL 5.*
Error upgrading from 3.4.2 to 3.4.3
June 14, 2011, 08:00:35 am
Just tried to upgrade and got this error

Code: [Select]
Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`CiviCRM`.`civicrm_uf_field`, CONSTRAINT `FK_civicrm_uf_field_location_type_id` FOREIGN KEY (`location_type_id`) REFERENCES `civicrm_location_type` (`id`) ON DELETE SET NULL), 1452
Additional Details:

Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -3
    [message] => DB Error: constraint violation
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_uf_field
   ( uf_group_id, field_name, is_required, is_reserved, weight, visibility, in_selector, is_searchable, location_type_id, label, field_type, help_post, phone_type_id )

VALUES
   ( @uf_group_id_onBehalfOrganization,   'organization_name',  1, 0, 1, 'User and User Admin Only',  0, 0, NULL,
            'Organization Name', 'Organization', NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'phone',              1, 0, 2, 'User and User Admin Only',  0, 0, 3,
            'Phone (Main) ',     'Contact',      NULL,  1 ),
   ( @uf_group_id_onBehalfOrganization,   'email',              1, 0, 3, 'User and User Admin Only',  0, 0, 3, 
            'Email (Main) ',     'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'street_address',     1, 0, 4, 'User and User Admin Only',  0, 0, 3, 
            'Street Address',    'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'city',               1, 0, 5, 'User and User Admin Only',  0, 0, 3, 
            'City',              'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'postal_code',        1, 0, 6, 'User and User Admin Only',  0, 0, 3,
            'Postal Code',       'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'country',            1, 0, 7, 'User and User Admin Only',  0, 0, 3,
            'Country',           'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'state_province',     1, 0, 8, 'User and User Admin Only',  0, 0, 3,   
            'State / Province',  'Contact',      NULL,  NULL ) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`CiviCRM`.`civicrm_uf_field`, CONSTRAINT `FK_civicrm_uf_field_location_type_id` FOREIGN KEY (`location_type_id`) REFERENCES `civicrm_location_type` (`id`) ON DELETE SET NULL)]
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_uf_field
   ( uf_group_id, field_name, is_required, is_reserved, weight, visibility, in_selector, is_searchable, location_type_id, label, field_type, help_post, phone_type_id )

VALUES
   ( @uf_group_id_onBehalfOrganization,   'organization_name',  1, 0, 1, 'User and User Admin Only',  0, 0, NULL,
            'Organization Name', 'Organization', NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'phone',              1, 0, 2, 'User and User Admin Only',  0, 0, 3,
            'Phone (Main) ',     'Contact',      NULL,  1 ),
   ( @uf_group_id_onBehalfOrganization,   'email',              1, 0, 3, 'User and User Admin Only',  0, 0, 3, 
            'Email (Main) ',     'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'street_address',     1, 0, 4, 'User and User Admin Only',  0, 0, 3, 
            'Street Address',    'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'city',               1, 0, 5, 'User and User Admin Only',  0, 0, 3, 
            'City',              'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'postal_code',        1, 0, 6, 'User and User Admin Only',  0, 0, 3,
            'Postal Code',       'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'country',            1, 0, 7, 'User and User Admin Only',  0, 0, 3,
            'Country',           'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'state_province',     1, 0, 8, 'User and User Admin Only',  0, 0, 3,   
            'State / Province',  'Contact',      NULL,  NULL ) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`CiviCRM`.`civicrm_uf_field`, CONSTRAINT `FK_civicrm_uf_field_location_type_id` FOREIGN KEY (`location_type_id`) REFERENCES `civicrm_location_type` (`id`) ON DELETE SET NULL)]
    [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_uf_field
   ( uf_group_id, field_name, is_required, is_reserved, weight, visibility, in_selector, is_searchable, location_type_id, label, field_type, help_post, phone_type_id )

VALUES
   ( @uf_group_id_onBehalfOrganization,   'organization_name',  1, 0, 1, 'User and User Admin Only',  0, 0, NULL,
            'Organization Name', 'Organization', NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'phone',              1, 0, 2, 'User and User Admin Only',  0, 0, 3,
            'Phone (Main) ',     'Contact',      NULL,  1 ),
   ( @uf_group_id_onBehalfOrganization,   'email',              1, 0, 3, 'User and User Admin Only',  0, 0, 3, 
            'Email (Main) ',     'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'street_address',     1, 0, 4, 'User and User Admin Only',  0, 0, 3, 
            'Street Address',    'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'city',               1, 0, 5, 'User and User Admin Only',  0, 0, 3, 
            'City',              'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'postal_code',        1, 0, 6, 'User and User Admin Only',  0, 0, 3,
            'Postal Code',       'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'country',            1, 0, 7, 'User and User Admin Only',  0, 0, 3,
            'Country',           'Contact',      NULL,  NULL ),
   ( @uf_group_id_onBehalfOrganization,   'state_province',     1, 0, 8, 'User and User Admin Only',  0, 0, 3,   
            'State / Province',  'Contact',      NULL,  NULL ) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`CiviCRM`.`civicrm_uf_field`, CONSTRAINT `FK_civicrm_uf_field_location_type_id` FOREIGN KEY (`location_type_id`) REFERENCES `civicrm_location_type` (`id`) ON DELETE SET NULL)]"]
)

Hellllllp! please

chelcone

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Error upgrading from 3.4.2 to 3.4.3
June 14, 2011, 08:39:59 am
Looks like you may have deleted a location type. Did you ever do that?
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

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: Error upgrading from 3.4.2 to 3.4.3
June 15, 2011, 04:49:21 am
I think during upgrade we might want to handle this case when location type is deleted. May be make "Main" as reserved location type.

Kurund
Found this reply helpful? Support CiviCRM

Chelcone

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 1
  • CiviCRM version: 3.4.0
  • CMS version: Drupal 6.*
  • MySQL version: MySQL 5.*
Re: Error upgrading from 3.4.2 to 3.4.3
June 16, 2011, 12:39:18 am
I havent deleted any location types.

Any idea how i can fix it?

Chelcone

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 1
  • CiviCRM version: 3.4.0
  • CMS version: Drupal 6.*
  • MySQL version: MySQL 5.*
Re: Error upgrading from 3.4.2 to 3.4.3
June 16, 2011, 01:01:47 am
after saying that it does seem that Main is gone from my locaion type list.

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: Error upgrading from 3.4.2 to 3.4.3
June 16, 2011, 01:51:22 am
Can you add location type "Main" and check if that fixes your upgrade issue.

Kurund
Found this reply helpful? Support CiviCRM

Chelcone

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 1
  • CiviCRM version: 3.4.0
  • CMS version: Drupal 6.*
  • MySQL version: MySQL 5.*
Re: Error upgrading from 3.4.2 to 3.4.3
June 16, 2011, 02:38:53 am
I tried that and it didnt seem to work.

Chelcone

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 1
  • CiviCRM version: 3.4.0
  • CMS version: Drupal 6.*
  • MySQL version: MySQL 5.*
Re: Error upgrading from 3.4.2 to 3.4.3
June 16, 2011, 02:45:27 am
Ok i fixed it be adding main and then going into phpmyadmin and changing the ID for the location type of main to 3 as it was before. When I re-added it back in it had an ID of 6 so that obviously didn't cut it.

Thanks for the help chaps!

kreynen

  • I post occasionally
  • **
  • Posts: 105
  • Karma: 8
Re: Error upgrading from 3.4.2 to 3.4.3
June 16, 2011, 02:01:06 pm
I ran into this error when upgrading form 3.4 to 4 as well.  To fix it we temporary turned off the autoincrement setting on the id column of the civicrm_location_type table and manually entered the missing locations to match the id of the original table defaults.

(1, 'Home', 'HOME', 'Place of residence', 0, 1, 1),
(2, 'Work', 'WORK', 'Work location', 0, 1, NULL),
(3, 'Main', NULL, 'Main office location', 0, 1, NULL),
(4, 'Other', NULL, 'Other location', 0, 1, NULL),
(5, 'Billing', NULL, 'Billing Address location', 1, 1, NULL);

On our case Main and Other were missing.  Once those were restored, the update ran without error.

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: Error upgrading from 3.4.2 to 3.4.3
June 16, 2011, 09:18:35 pm
I have filed an issue to fix this upgrade issue: http://issues.civicrm.org/jira/browse/CRM-8318. It will be part of next release.

Kurund
Found this reply helpful? Support CiviCRM

gholt

  • I post occasionally
  • **
  • Posts: 79
  • Karma: 0
Re: Error upgrading from 3.4.2 to 3.4.3
June 24, 2011, 02:32:15 pm
Thanks to each of you for identifying the problem and providing enough information for the fix -- even for a beginner like me.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Error upgrading from 3.4.2 to 3.4.3

This forum was archived on 2017-11-26.