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) »
  • Upgrading 3.1.3 to 3.2.2: DB Error: constraint violation
Pages: [1]

Author Topic: Upgrading 3.1.3 to 3.2.2: DB Error: constraint violation  (Read 833 times)

Sean123

  • Guest
Upgrading 3.1.3 to 3.2.2: DB Error: constraint violation
September 03, 2010, 07:44:37 am
Hi all.

Please help! I receive a DB Error: constraint violation when upgrading. I've searched the forums but cannot work out what steps I need to do to fix this. Any help is greatly appreciated. The full error details are:

Code: [Select]
Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`amsaorga_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 ) VALUES
   ( @uf_group_id_summary,           'phone' ,1,        0, 1,     'User and User Admin Only',   0,   0, 1,   'Home Phone', 'Contact'),
   ( @uf_group_id_summary,           'phone' ,1,      0, 2,     'User and User Admin Only',   0,      0, 2,   'Home Mobile', 'Contact' ),
   ( @uf_group_id_summary, 'street_address',   1,    0, 3,   'User and User Admin Only',   0,   0, NULL,    'Primary Address',         'Contact' ),
   ( @uf_group_id_summary, 'city',   1,    0, 4,   'User and User Admin Only',   0,   0, NULL,    'City',  'Contact' ),
   ( @uf_group_id_summary, 'state_province',   1,    0, 5,   'User and User Admin Only',   0,   0, NULL,    'State',  'Contact' ),
   ( @uf_group_id_summary, 'postal_code',   1,    0, 6,   'User and User Admin Only',   0,   0, NULL,    'Postal Code',  'Contact' ),
   ( @uf_group_id_summary, 'email',   1,    0, 7,   'User and User Admin Only',   0,   0, NULL,    'Primary Email',  'Contact' ),
   ( @uf_group_id_summary, 'group',   1,    0, 8,   'User and User Admin Only',   0,   0, NULL,    'Groups',  'Contact' ),
   ( @uf_group_id_summary, 'tag',   1,    0, 9,   'User and User Admin Only',   0,   0,      NULL,    'Tags', 'Contact' ),
   ( @uf_group_id_summary,           'gender',    1,         0,  10,  'User and User Admin Only',   0,    0,  NULL,  'Gender',  'Individual' ),
   ( @uf_group_id_summary,      'birth_date',   1,         0, 11, 'User and User Admin Only',   0,   0, NULL,   'Date of Birth',     'Individual' ) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`amsaorga_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 ) VALUES
   ( @uf_group_id_summary,           'phone' ,1,        0, 1,     'User and User Admin Only',   0,   0, 1,   'Home Phone', 'Contact'),
   ( @uf_group_id_summary,           'phone' ,1,      0, 2,     'User and User Admin Only',   0,      0, 2,   'Home Mobile', 'Contact' ),
   ( @uf_group_id_summary, 'street_address',   1,    0, 3,   'User and User Admin Only',   0,   0, NULL,    'Primary Address',         'Contact' ),
   ( @uf_group_id_summary, 'city',   1,    0, 4,   'User and User Admin Only',   0,   0, NULL,    'City',  'Contact' ),
   ( @uf_group_id_summary, 'state_province',   1,    0, 5,   'User and User Admin Only',   0,   0, NULL,    'State',  'Contact' ),
   ( @uf_group_id_summary, 'postal_code',   1,    0, 6,   'User and User Admin Only',   0,   0, NULL,    'Postal Code',  'Contact' ),
   ( @uf_group_id_summary, 'email',   1,    0, 7,   'User and User Admin Only',   0,   0, NULL,    'Primary Email',  'Contact' ),
   ( @uf_group_id_summary, 'group',   1,    0, 8,   'User and User Admin Only',   0,   0, NULL,    'Groups',  'Contact' ),
   ( @uf_group_id_summary, 'tag',   1,    0, 9,   'User and User Admin Only',   0,   0,      NULL,    'Tags', 'Contact' ),
   ( @uf_group_id_summary,           'gender',    1,         0,  10,  'User and User Admin Only',   0,    0,  NULL,  'Gender',  'Individual' ),
   ( @uf_group_id_summary,      'birth_date',   1,         0, 11, 'User and User Admin Only',   0,   0, NULL,   'Date of Birth',     'Individual' ) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`amsaorga_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 ) VALUES
   ( @uf_group_id_summary,           'phone' ,1,        0, 1,     'User and User Admin Only',   0,   0, 1,   'Home Phone', 'Contact'),
   ( @uf_group_id_summary,           'phone' ,1,      0, 2,     'User and User Admin Only',   0,      0, 2,   'Home Mobile', 'Contact' ),
   ( @uf_group_id_summary, 'street_address',   1,    0, 3,   'User and User Admin Only',   0,   0, NULL,    'Primary Address',         'Contact' ),
   ( @uf_group_id_summary, 'city',   1,    0, 4,   'User and User Admin Only',   0,   0, NULL,    'City',  'Contact' ),
   ( @uf_group_id_summary, 'state_province',   1,    0, 5,   'User and User Admin Only',   0,   0, NULL,    'State',  'Contact' ),
   ( @uf_group_id_summary, 'postal_code',   1,    0, 6,   'User and User Admin Only',   0,   0, NULL,    'Postal Code',  'Contact' ),
   ( @uf_group_id_summary, 'email',   1,    0, 7,   'User and User Admin Only',   0,   0, NULL,    'Primary Email',  'Contact' ),
   ( @uf_group_id_summary, 'group',   1,    0, 8,   'User and User Admin Only',   0,   0, NULL,    'Groups',  'Contact' ),
   ( @uf_group_id_summary, 'tag',   1,    0, 9,   'User and User Admin Only',   0,   0,      NULL,    'Tags', 'Contact' ),
   ( @uf_group_id_summary,           'gender',    1,         0,  10,  'User and User Admin Only',   0,    0,  NULL,  'Gender',  'Individual' ),
   ( @uf_group_id_summary,      'birth_date',   1,         0, 11, 'User and User Admin Only',   0,   0, NULL,   'Date of Birth',     'Individual' ) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`amsaorga_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)]"]
)

Can anyone help me decipher what I might be able to do to fix this?

Thank you!![/code]

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Upgrading 3.1.3 to 3.2.2: DB Error: constraint violation
September 03, 2010, 09:02:38 am

seems like u deleted one or more records from the location type table and hence the FK constrain error

u might want to ensure that u have id's 1 to 3 in that table

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Upgrading 3.1.3 to 3.2.2: DB Error: constraint violation

This forum was archived on 2017-11-26.