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 »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Even AFtER Database Integrity Check, Foreign Key Contstraint Fails on Upgrade
Pages: [1]

Author Topic: Even AFtER Database Integrity Check, Foreign Key Contstraint Fails on Upgrade  (Read 863 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
Even AFtER Database Integrity Check, Foreign Key Contstraint Fails on Upgrade
July 13, 2010, 11:37:34 pm
Hi there...successfully upgraded a site from 2.2.6 to 3.0.3 (I have no idea what the site originally was installed as)

Ran into a constraint violation from 3.0.3 to 3.1.5, so I followed the instructions laid out here:
http://wiki.civicrm.org/confluence/display/CRMUPCOMING/Ensuring+Schema+Integrity+on+Upgrades

That seems to have had no effect.  I still get the same error.  I went to backups and am roadblocked at 3.0.3, still using my fresh schema with the data, which is working fine....but...no 3.1. or 3.2 until I get this solved.

One thing that is interesting about this site is they do use custom data on user profiles as well as personal contribution pages, and sure enough personal contribution pages seems to be exactly what this constraint violation is about: CONSTRAINT `FK_civicrm_contribution_soft_pcp_id` FOREIGN KEY (`pcp_id`)  This is kind of a rare combo perhaps, and may have caused some heretofore unknown bugs.

Any ideas for a fix?  I can give senior developers logins to the site if you want.


Code: [Select]
   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 (`namilou_civicrm/#sql-6dd8_46a626`, CONSTRAINT `FK_civicrm_contribution_soft_pcp_id` FOREIGN KEY (`pcp_id`) REFERENCES `civicrm_pcp` (`id`) ON DELETE SET NULL), 1452

    Return to home page.

Error Details:

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

    [code] => -3
    [message] => DB Error: constraint violation
    [mode] => 16
    [debug_info] => ALTER TABLE `civicrm_contribution_soft`
    ADD CONSTRAINT `FK_civicrm_contribution_soft_pcp_id` FOREIGN KEY (`pcp_id`) REFERENCES `civicrm_pcp` (`id`) ON DELETE SET NULL [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`namilou_civicrm/#sql-6dd8_46a626`, CONSTRAINT `FK_civicrm_contribution_soft_pcp_id` FOREIGN KEY (`pcp_id`) REFERENCES `civicrm_pcp` (`id`) ON DELETE SET NULL)]
    [type] => DB_Error
    [user_info] => ALTER TABLE `civicrm_contribution_soft`
    ADD CONSTRAINT `FK_civicrm_contribution_soft_pcp_id` FOREIGN KEY (`pcp_id`) REFERENCES `civicrm_pcp` (`id`) ON DELETE SET NULL [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`namilou_civicrm/#sql-6dd8_46a626`, CONSTRAINT `FK_civicrm_contribution_soft_pcp_id` FOREIGN KEY (`pcp_id`) REFERENCES `civicrm_pcp` (`id`) ON DELETE SET NULL)]
    [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="ALTER TABLE `civicrm_contribution_soft`
    ADD CONSTRAINT `FK_civicrm_contribution_soft_pcp_id` FOREIGN KEY (`pcp_id`) REFERENCES `civicrm_pcp` (`id`) ON DELETE SET NULL [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`namilou_civicrm/#sql-6dd8_46a626`, CONSTRAINT `FK_civicrm_contribution_soft_pcp_id` FOREIGN KEY (`pcp_id`) REFERENCES `civicrm_pcp` (`id`) ON DELETE SET NULL)]"]
)
[/code]
« Last Edit: July 13, 2010, 11:54:50 pm by Stoob »
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Deepak Srivastava

  • Moderator
  • Ask me questions
  • *****
  • Posts: 677
  • Karma: 65
Re: Even AFtER Database Integrity Check, Foreign Key Contstraint Fails on Upgrade
July 14, 2010, 12:40:07 am
Sounds like there are orphan entries in civicrm_contribution_soft table pointing to non existing entry in civicrm_pcp which is causing constraint to break.

You will need to retrieve those entries & set the pointer to null.
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

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: Even AFtER Database Integrity Check, Foreign Key Contstraint Fails on Upgrade
July 14, 2010, 11:17:17 pm
thank you deepak.  I set over 200 records pcp_id = NULL where the pcp_id did not exist in civicrm_pcp.   the upgrade worked to 3.1.5!   the users had deleted many of their old pcp pages from the database, leaving orphans in this table.

I guess it is not a good idea to delete pcp pages?
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Even AFtER Database Integrity Check, Foreign Key Contstraint Fails on Upgrade

This forum was archived on 2017-11-26.