Support (offered by community volunteers) > Using Core CiviCRM Functions
Odd random problem: Cannot delete contact(s)
(1/1)
bob schmitt:
Drupal 4.7, CiviCRM 1.7
I'm playing with a registration process and doing a lot of tests, so I need to periodically delete a bunch of test contacts. Sometimes I can, no problem. Sometimes I can't, with this message:
--- Code: ---
Database Error Code: Cannot delete or update a parent row: a foreign key constraint fails, 1217
Return to CiviCRM menu.
Error Details:
Array
(
[callback] => Array
(
[0] => CRM_Core_Error
[1] => handle
)
[code] => -3
[message] => DB Error: constraint violation
[mode] => 16
[debug_info] => DELETE FROM civicrm_contact WHERE ( civicrm_contact.id = 771 ) [nativecode=1217 ** Cannot delete or update a parent row: a foreign key constraint fails]
[type] => db_error
[user_info] => DELETE FROM civicrm_contact WHERE ( civicrm_contact.id = 771 ) [nativecode=1217 ** Cannot delete or update a parent row: a foreign key constraint fails]
[to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="DELETE FROM civicrm_contact WHERE ( civicrm_contact.id = 771 ) [nativecode=1217 ** Cannot delete or update a parent row: a foreign key constraint fails]"]
)
--- End code ---
Here's where it gets weird: Sometimes I can delete the contacts by only selecting a couple of the contacts, then deleting them. Other times, I can delete the contacts only by viewing the individual contact record, and deleting from there.
Othertimes, I cannot delete a contact at all.
Any clues about how to resolve this would be helpful. We normally don't delete much, but I've been running tests all day and need to recover the accounts so I can reuse the test email accounts.
bob
[/code]
Dave Greenberg:
Bob - We've seen several causes of this at different times - most of which I think have been corrected (some in the upcoming 1.8 release :-) ).
Some things to check:
* Contact(s) assigned to CiviMember memberships, and then CiviMember is disabled - so delete doesn't cleanup related membership records. If this scenario is a possibility, re-enabling CiviMember should fix it.
* Trying to delete a contact associated w/ a user who has been updating other contacts (and hence they are referenced in civicrm_log).
* Others along this line...
If you have easy access to mysql command line or phpMyAdmin - run some selects against the contact_id (771) on tables w/ FK's to civicrm_contact.id. Let us know what you find (or if you need more guidance to debug).
dave
bob schmitt:
Hey Dave-
I did two things:
a) enabled CiviMember and
b) upgraded the code to the June 8 version of 1.7.
So far, no problems...(my test contacts deleted just fine) but I haven't poked this as much today. I'll debug further if this happens again.
Hopefully this is resolved. Thanks for the clues!
Navigation
[0] Message Index
Go to full version