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 CiviMail (Moderator: Piotr Szotkowski) »
  • Unable to delete mailings: foreign key issue
Pages: [1]

Author Topic: Unable to delete mailings: foreign key issue  (Read 1132 times)

wmostrey

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 3
    • Wim Mostrey
Unable to delete mailings: foreign key issue
July 14, 2008, 03:09:50 am
On CiviCRM 1.7 when I try to delete a mailing I get the following error:

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

Database Error Code: Cannot delete or update a parent row: a foreign key constraint fails (`mtabco_civicrm/civicrm_mailing_event_queue`, CONSTRAINT `FK_civicrm_mailing_event_queue_job_id` FOREIGN KEY (`job_id`) REFERENCES `civicrm_mailing_job` (`id`)), 1451

Code: [Select]
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_mailing_job  WHERE (  civicrm_mailing_job.id = 9 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`mtabco_civicrm/civicrm_mailing_event_queue`, CONSTRAINT `FK_civicrm_mailing_event_queue_job_id` FOREIGN KEY (`job_id`) REFERENCES `civicrm_mailing_job` (`id`))]
    [type] => DB_Error
    [user_info] => DELETE FROM civicrm_mailing_job  WHERE (  civicrm_mailing_job.id = 9 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`mtabco_civicrm/civicrm_mailing_event_queue`, CONSTRAINT `FK_civicrm_mailing_event_queue_job_id` FOREIGN KEY (`job_id`) REFERENCES `civicrm_mailing_job` (`id`))]
    [to_string] => [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::handle prefix="" info="DELETE FROM civicrm_mailing_job  WHERE (  civicrm_mailing_job.id = 9 )  [nativecode=1451 ** Cannot delete or update a parent row: a foreign key constraint fails (`mtabco_civicrm/civicrm_mailing_event_queue`, CONSTRAINT `FK_civicrm_mailing_event_queue_job_id` FOREIGN KEY (`job_id`) REFERENCES `civicrm_mailing_job` (`id`))]"]
)

I saw several other issues on the forum regarding foreign key issues when deleting contacts or groups, but most of the could be solved by truncating the civicrm_acl_cache table. This is not the case here. Is there a .sql file or sql statement I could run to fix this?[/code]
« Last Edit: July 14, 2008, 10:12:47 am by wmostrey »

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: Unable to delete mailings: foreign key issue
July 14, 2008, 12:08:36 pm

The below error indicates that we need to delete the specific mailing id entries from civicrm_event_queue before deleting civicrm_mailing_job. You'll need to follow that and ensure that all tables with an FK to event_queue are deleted before deleting event_queue etc ..

In 2.0 and later we use cascaded constraints and let the db do all the hard work :). That might be the other option of augmenting your schema and adding the constraints. you can check the 2.0 schema to get an idea of the constraints needed

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

wmostrey

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 3
    • Wim Mostrey
Re: Unable to delete mailings: foreign key issue
July 15, 2008, 02:03:06 am
Perfect, thanks a lot for the tip. I enabled the cascaded constraints and things work as expected now.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • Unable to delete mailings: foreign key issue

This forum was archived on 2017-11-26.