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 »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Error when attempting to delete Contacts
Pages: [1]

Author Topic: Error when attempting to delete Contacts  (Read 2372 times)

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Error when attempting to delete Contacts
March 28, 2008, 01:45:11 pm
Hi, I am attempting to delete all our contacts and then reimport them.   We have about 12,000 rows.  About half way through the delete I get an error.  I've tried it twice now.  Same thing.   I am deleting by "Find Contacts" with no parameters (so all Contacts are returned) and then selecting all the contacts and selecting "Delete" them from the dropdown.

Here is the error.  What can I do to fix this problem?  Please help.

Code: [Select]

Database Error Code: Cannot delete or update a parent row: a foreign key constraint fails (`civicrm/civicrm_note`, CONSTRAINT `FK_civicrm_note_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`)), 1451


----------------------------------------------------------------------

Error Details:

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

    [code] => -1
    [message] => DB Error: unknown error
    [mode] => 16
    [debug_info] => DELETE FROM civicrm_contact  WHERE (  civicrm_contact.id = 6272 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`civicrm/civicrm_note`, CONSTRAINT `FK_civicrm_note_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`))]
    [type] => DB_Error
    [user_info] => DELETE FROM civicrm_contact  WHERE (  civicrm_contact.id = 6272 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`civicrm/civicrm_note`, CONSTRAINT `FK_civicrm_note_contact_id` FOREIGN KEY (`contact_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="DELETE FROM civicrm_contact  WHERE (  civicrm_contact.id = 6272 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`civicrm/civicrm_note`, CONSTRAINT `FK_civicrm_note_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`))]"]
)

--------------------------------------------------------------------------------------------------
backTrace

/var/www/html/rn/sites/all/modules/civicrm/CRM/Core/Error.php, backtrace, 148
, handle,
/var/www/html/rn/sites/all/modules/civicrm/packages/PEAR.php, call_user_func, 901
/var/www/html/rn/sites/all/modules/civicrm/packages/DB.php, PEAR_Error, 888
/var/www/html/rn/sites/all/modules/civicrm/packages/PEAR.php, DB_Error, 563
/var/www/html/rn/sites/all/modules/civicrm/packages/DB/common.php, raiseError, 1849
/var/www/html/rn/sites/all/modules/civicrm/packages/DB/mysql.php, raiseError, 894
/var/www/html/rn/sites/all/modules/civicrm/packages/DB/mysql.php, mysqlRaiseError, 324
/var/www/html/rn/sites/all/modules/civicrm/packages/DB/common.php, simpleQuery, 1162
/var/www/html/rn/sites/all/modules/civicrm/packages/DB/DataObject.php, query, 2343
/var/www/html/rn/sites/all/modules/civicrm/packages/DB/DataObject.php, _query, 1394
/var/www/html/rn/sites/all/modules/civicrm/CRM/Contact/BAO/Contact.php, delete, 988
/var/www/html/rn/sites/all/modules/civicrm/CRM/Contact/Form/Task/Delete.php, deleteContact, 114
/var/www/html/rn/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Done.php, postProcess, 79
/var/www/html/rn/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php, perform, 195
/var/www/html/rn/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php, handle, 95
/var/www/html/rn/sites/all/modules/civicrm/CRM/Core/Controller.php, handle, 223
/var/www/html/rn/sites/all/modules/civicrm/CRM/Core/Invoke.php, run, 540
/var/www/html/rn/sites/all/modules/civicrm/CRM/Core/Invoke.php, search, 435
/var/www/html/rn/sites/all/modules/civicrm/CRM/Core/Invoke.php, contact, 98
/var/www/html/rn/sites/all/modules/civicrm/drupal/civicrm.module, invoke, 321
, civicrm_invoke,
/var/www/html/rn/includes/menu.inc, call_user_func_array, 418
/var/www/html/rn/index.php, menu_execute_active_handler, 15
[/code]
« Last Edit: March 28, 2008, 01:47:07 pm by Stoob »
Try CiviTeacher: the online video tutorial CiviCRM learning library.

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: Error when attempting to delete Contacts
March 28, 2008, 01:53:24 pm

this has been filed and fixed: http://issues.civicrm.org/jira/browse/CRM-2887

will be part of 2.0.2

If you are familiar with sql, you can extend the 'contact_id' constraint to add "ON DELETE SET NULL". You should also make that FK optional (this change will be in 2.1). If the previous statements seem like a different language,  please wait for 2.0.2 :)

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

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Error when attempting to delete Contacts
March 28, 2008, 02:25:26 pm
I'm familiar with MySQL but don't have any idea where to make those code changes in the file system.  When is 2.0.2 due out? 

Gracias.
Try CiviTeacher: the online video tutorial CiviCRM learning library.

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: Error when attempting to delete Contacts
March 28, 2008, 05:54:26 pm

Those changes do not involve the file system :) they are mysql changes only. The valid behavior is to get the database to set the contact_id to null in note when deleted

2.0.2 will be out hopefully mid next week

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

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Error when attempting to delete Contacts
March 28, 2008, 08:03:54 pm
Well I tried adding that to the constraint but then got a MySQL error number 150.  I looked that up on this page http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html and then became confused.  We are in the middle of a data migration.  Any other help that you could give on how to resolve this problem would be GREAT, please!   It would kind of be not-awesome to wait until late next week to migrate this data.

Thanks.k.
Try CiviTeacher: the online video tutorial CiviCRM learning library.

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: Error when attempting to delete Contacts
March 28, 2008, 10:02:20 pm

you have a few options:

1. update using svn, that way you will get the fix since it already part of the codebase (installation instruction from svn are on the wiki)

2. You can specifically patch the files that were used for this fix. The diffs can be seen here:

http://issues.civicrm.org/jira/browse/CRM-2887?page=com.atlassian.jira.ext.fisheye:fisheye-issuepanel

You need to integrate the 13747 and 13748 changes

3. Work with someone familiar with mysql and add it as a db constraint. If you get on IRC we can help you out a wee bit (we are not too strong on sql)

4. finally, if things go smoothly, the 2.0.2 release is planned for either tues or wed, so its not too far off

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

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Error when attempting to delete Contacts
March 29, 2008, 10:29:17 am
Holy cow the patch worked.  Thanks Lobo. 
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Error when attempting to delete Contacts

This forum was archived on 2017-11-26.