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 »
  • Installing CiviCRM »
  • CiviMail installation and configuration (Moderator: Donald Lobo) »
  • Synchronize Users to Contacts w/ Drupal - foreign key constraint fails
Pages: [1]

Author Topic: Synchronize Users to Contacts w/ Drupal - foreign key constraint fails  (Read 2960 times)

jwade

  • Guest
Synchronize Users to Contacts w/ Drupal - foreign key constraint fails
February 18, 2008, 11:58:41 am
I have an existing Drupal installation and am trying to get CiviCRM to work with it.  I have many Drupal users and I want to synchronize them with CiviCRM but I get this error when attempting it:

Code: [Select]
unrecoverable error
    Sorry. A non-recoverable error has occurred.

Error Details:

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

    [code] => -1
    [message] => DB Error: unknown error
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' ,  3 , 'civicrm_contact,3' ,  102 ,  20080218112823 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`civicrm/civicrm_log`, CONSTRAINT `FK_civicrm_log_modified_id` FOREIGN KEY (`modified_id`) REFERENCES `civicrm_contact` (`id`))]
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' ,  3 , 'civicrm_contact,3' ,  102 ,  20080218112823 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`civicrm/civicrm_log`, CONSTRAINT `FK_civicrm_log_modified_id` FOREIGN KEY (`modified_id`) REFERENCES `civicrm_contact` (`id`))]
    [to_string] => [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' ,  3 , 'civicrm_contact,3' ,  102 ,  20080218112823 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`civicrm/civicrm_log`, CONSTRAINT `FK_civicrm_log_modified_id` FOREIGN KEY (`modified_id`) REFERENCES `civicrm_contact` (`id`))]"]
)
I am fairly experienced with Drupal (as well as Apache, Php, and MySQL), but this is my first experience with CiviCRM.  I did not seem to have any difficulties or errors installing CiviCRM (1.9.13019-drupal) using the automatic installation script, but I did not elect to load the sample data (if that matters).

How do I go about troubleshooting this?

Thanks and regards,
~ j.Wade

[/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: Synchronize Users to Contacts w/ Drupal - foreign key constraint fails
February 18, 2008, 12:13:48 pm

i think you might have loaded sample data at some stage (based on the contact id 102) and then potentially reset the database?

can you please truncate your drupal sessions table and try the operation again

thanx

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

jwade

  • Guest
Re: Synchronize Users to Contacts w/ Drupal - foreign key constraint fails
February 19, 2008, 12:41:15 pm
Quote
i think you might have loaded sample data at some stage (based on the contact id 102) and then potentially reset the database?

Yes, I originally did load the sample data, then reset the database.

Quote
can you please truncate your drupal sessions table and try the operation again

I've done that, and that seems to have fixed that problem.  However, I'm now getting this error message:
Code: [Select]
Error Details:

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

    \[code] => -5
    [message] => DB Error: already exists
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_uf_match (uf_id , contact_id , domain_id , email ) VALUES ( 275 ,  177 ,  1 , 'foo@bar.com' )  [nativecode=1062 ** Duplicate entry '177' for key 3]
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_uf_match (uf_id , contact_id , domain_id , email ) VALUES ( 275 ,  177 ,  1 , 'foo@bar.com' )  [nativecode=1062 ** Duplicate entry '177' for key 3]
    [to_string] => [db_error: message="DB Error: already exists" code=-5 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_uf_match (uf_id , contact_id , domain_id , email ) VALUES ( 275 ,  177 ,  1 , 'foo@bar.com' )  [nativecode=1062 ** Duplicate entry '177' for key 3]"]
)

I found that I had two accounts in Drupal with the same email address, so I deleted the one that didn't belong in Drupal and started over with CiviCRM, but I'm still getting this error!

Doesn't the "uf_id" above come from the "user.uid" field in Drupal?  I no longer have a user with uid=275.  (That is the one I deleted.)  Why is it still showing up?

I appreciate the assistance,
~ j.Wade
[/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: Synchronize Users to Contacts w/ Drupal - foreign key constraint fails
February 19, 2008, 12:48:43 pm

You might want to double check and ensure it is deleted. civicrm gets the uf_id from the users table, so if its showing up, i suspect  it is still present in your users table.

you might also want to delete the entry from the uf_match table just to keep things clean and consistent

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

jwade

  • Guest
Re: Synchronize Users to Contacts w/ Drupal - foreign key constraint fails
February 20, 2008, 10:37:45 am
Thanks for your help.  I finally found the problem.  I am installing CiviCRM on a copy of my live site, but I forgot to set it to use the database copy.  I had entered the name of the live database instead.

Once I had CiviCRM pointed at the correct database, I found and fixed two instances of multiple usernames with the same email address.  After removing those duplicates, the synchronization worked flawlessly.

Again, I really appreciate your help with this.

Regards,
~ j.wade

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • CiviMail installation and configuration (Moderator: Donald Lobo) »
  • Synchronize Users to Contacts w/ Drupal - foreign key constraint fails

This forum was archived on 2017-11-26.