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) »
  • Foreign Key error in CiviContribute after upgrade to 2.0.1
Pages: [1]

Author Topic: Foreign Key error in CiviContribute after upgrade to 2.0.1  (Read 1608 times)

mswyrick

  • Guest
Foreign Key error in CiviContribute after upgrade to 2.0.1
March 24, 2008, 01:19:45 am
Hello all.  I updated my Drupal CiviCRM installation from 1.9.12432 to 2.01 without any error or problems.  Everything has worked so far except for the membership sign up page in CiviContribute.  All other features of CivicContribute work except member signup/renewal.  I'm relatively new to Drupal/CiviCRM and I'm not sure how to try to fix this.  Error is shown Below.

     Sorry. A non-recoverable error has occurred.

    Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`civicrmhome/civicrm_membership`, CONSTRAINT `FK_civicrm_membership_status_id` FOREIGN KEY (`status_id`) REFERENCES `civicrm_membership_status` (`id`) ON DELETE CASCADE), 1452

    Return to home page.

Error Details:
 
Code: [Select]
Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => handle
        )

    [code] => -1
    [message] => DB Error: unknown error
    [mode] => 16
    [debug_info] => INSERT INTO civicrm_membership (contact_id , membership_type_id , source , status_id , is_override , is_test ) VALUES ( 102 ,  1 , 'Online Contribution: CBF Member' ,  5 ,  0 ,  1 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`civicrmhome/civicrm_membership`, CONSTRAINT `FK_civicrm_membership_status_id` FOREIGN KEY (`status_id`) REFERENCES `civicrm_membership_status` (`id`) ON DELETE CASCADE)]
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_membership (contact_id , membership_type_id , source , status_id , is_override , is_test ) VALUES ( 102 ,  1 , 'Online Contribution: CBF Member' ,  5 ,  0 ,  1 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`civicrmhome/civicrm_membership`, CONSTRAINT `FK_civicrm_membership_status_id` FOREIGN KEY (`status_id`) REFERENCES `civicrm_membership_status` (`id`) ON DELETE CASCADE)]
    [to_string] => [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_membership (contact_id , membership_type_id , source , status_id , is_override , is_test ) VALUES ( 102 ,  1 , 'Online Contribution: CBF Member' ,  5 ,  0 ,  1 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`civicrmhome/civicrm_membership`, CONSTRAINT `FK_civicrm_membership_status_id` FOREIGN KEY (`status_id`) REFERENCES `civicrm_membership_status` (`id`) ON DELETE CASCADE)]"]
)
 
[/code]

Deepak Srivastava

  • Moderator
  • Ask me questions
  • *****
  • Posts: 677
  • Karma: 65
Re: Foreign Key error in CiviContribute after upgrade to 2.0.1
March 24, 2008, 07:47:33 am
Go to CiviCRM >> Administer CiviCRM >> Membership Status Rules, and check if you have 'Pending' and 'Cancelled' status listed.

If NOT,
create same with the same information as you see on http://drupal.demo.civicrm.org/civicrm/admin/member/membershipStatus?reset=1

OR if you would like to do the same thing with query, here it is:
Code: [Select]
INSERT INTO civicrm_membership_status ( `domain_id`, `name`, `start_event`, `start_event_adjust_unit`, `start_event_adjust_interval`, `end_event`, `end_event_adjust_unit`, `end_event_adjust_interval`, `is_current_member`, `is_admin`, `weight`, `is_default`, `is_active`) VALUES
( @domain_id , 'Pending', 'join_date', NULL, NULL, 'join_date', NULL, NULL, 0, 0, 5, 0, 1),
( @domain_id , 'Cancelled', 'join_date', NULL, NULL, 'join_date', NULL, NULL, 0, 0, 6, 0, 1);

where "@domain_id" is your domain id.

Upgrade script (v2.01) had missed this part. The fix has already been done (rev: 13714) and will be available with next 2.0 related release.
« Last Edit: March 24, 2008, 07:52:18 am by Deepak Srivastava »
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

mswyrick

  • Guest
Re: Foreign Key error in CiviContribute after upgrade to 2.0.1
March 24, 2008, 11:45:06 am
Quick fix.  Thank you very much.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Foreign Key error in CiviContribute after upgrade to 2.0.1

This forum was archived on 2017-11-26.