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 »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • DB Error: constraint violation [Cannot add or update a child row: a foreign key]
Pages: [1]

Author Topic: DB Error: constraint violation [Cannot add or update a child row: a foreign key]  (Read 2479 times)

newubik

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
DB Error: constraint violation [Cannot add or update a child row: a foreign key]
July 10, 2010, 02:52:34 am
After installing CiviCRM on Drupal the message said that installation was successful, but when I turned back to administration, the new CiviCRM menu item was missing.
More than this, when I`m trying to access http://mysite.com/civicrm/admin/setting/updateConfigBackend?reset=1, I get the following error message:


---------------------------------------------------------------------------------------------------------------------
Sorry. A non-recoverable error has occurred.
DB Error: constraint violation
Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`newsletter/civicrm_acl_cache`, CONSTRAINT `FK_civicrm_acl_cache_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE), 1452
---------------------------------------------------------------------------------------------------------------------



When I`m trying to force CiviCRM section like this: http://mysite.com/civicrm/dashboard, I get the same error.
The error details are below:


-------------------------------------------------------------------------------------------------
Array
(
    [callback] => Array
        (
            
  • => CRM_Core_Error
  • [1] => handle
            )

        #code# => -3
        #message# => DB Error: constraint violation
        #mode# => 16
        #debug_info# => INSERT INTO civicrm_acl_cache (contact_id , acl_id ) VALUES ( 102 ,  2 )  
[nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`newsletter/civicrm_acl_cache`, CONSTRAINT `FK_civicrm_acl_cache_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
    #type# => DB_Error
    #user_info# => INSERT INTO civicrm_acl_cache (contact_id , acl_id ) VALUES ( 102 ,  2 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`newsletter/civicrm_acl_cache`, CONSTRAINT `FK_civicrm_acl_cache_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
    #to_string# => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_acl_cache (contact_id , acl_id ) VALUES ( 102 ,  2 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`newsletter/civicrm_acl_cache`, CONSTRAINT `FK_civicrm_acl_cache_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]"]
)
-------------------------------------------------------------------------------------------------



I mention that I`m using CiviCRM 3.1.0, Drupal 6.17, PHP 5.2.11 and MySQL Client: 5.0.86


On my localhost I use CiviCRM 3.1.0, Drupal 6.17, PHP 5.2.9 and MySQL Client: 5.0.51a and everything works fine.


What can be the issue?
It seems like a mysql bug, but I`m not sure.
Is there anybody facing the same problem who can share the solution with me?



Thank you.


« Last Edit: July 10, 2010, 05:32:08 am by newubik »

newubik

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
Re: CiviCRM menu item doesn`t show up
July 10, 2010, 05:28:44 am
Me again:

The ticking/unticking fix from dgh helped me to get CiviCRM menu item back in admin menu, but the error continue to persist.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: DB Error: constraint violation [Cannot add or update a child row: a foreign key]
July 10, 2010, 06:37:28 am
Hi,

Pretty sure it isn't a bug. Logout/login.

What is contact 102 ? did you upload it with demo contacts ?

(or transfered from the db on your dev server ?)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

newubik

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
Re: DB Error: constraint violation [Cannot add or update a child row: a foreign key]
July 10, 2010, 07:13:32 am
Yes, I installed it with demo data.
But I did the same thing on my localhost and everything works fine.
I didn't have any problem.
I repeated the process twice both on my local an on the server with similar results.


PS:

When I try to run the same query directly in phpMyAdmin I get this error:

--------------------------------------------------------------------------------------------------------------------
#1452 - Cannot add or update a child row: a foreign key constraint fails (`newsletter/civicrm_acl_cache`, CONSTRAINT `FK_civicrm_acl_cache_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)
--------------------------------------------------------------------------------------------------------------------
« Last Edit: July 10, 2010, 07:17:26 am by newubik »

Piotr Szotkowski

  • Moderator
  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: DB Error: constraint violation [Cannot add or update a child row: a foreign key]
July 27, 2010, 08:50:42 am
Can you try logging out, clearing the civicrm_acl_cache table and logging in back again?
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • DB Error: constraint violation [Cannot add or update a child row: a foreign key]

This forum was archived on 2017-11-26.