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 CiviMember (Moderator: Deepak Srivastava) »
  • Foreign Key Constraint on Membership_Log Table
Pages: [1]

Author Topic: Foreign Key Constraint on Membership_Log Table  (Read 1335 times)

hintbw

  • I’m new here
  • *
  • Posts: 20
  • Karma: 1
    • AzTEA
Foreign Key Constraint on Membership_Log Table
January 05, 2009, 10:35:00 am
We recently upgraded to Drupal 6 and CiviCRM 2.1 from our Drupal 5 and CiviCRM 1.8 installation. The first person to come in and try and update received a fatal error saying that there was a foreign key constraint issue with the status_id column in the membership log and the id column in the civicrm_membership_status table.


    [debug_info] => INSERT INTO civicrm_membership_log (membership_id , start_date , end_date , modified_id , modified_date , renewal_reminder_date ) VALUES ( 2376 ,  20071103 ,  20081102 ,  1425 ,  20090105 ,  00000 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`aztea_civicrm/civicrm_membership_log`, CONSTRAINT `FK_civicrm_membership_log_status_id` FOREIGN KEY (`status_id`) REFERENCES `civicrm_membership_status` (`id`) ON DELETE CASCADE)]
    [type] => DB_Error
    [user_info] => INSERT INTO civicrm_membership_log (membership_id , start_date , end_date , modified_id , modified_date , renewal_reminder_date ) VALUES ( 2376 ,  20071103 ,  20081102 ,  1425 ,  20090105 ,  00000 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`aztea_civicrm/civicrm_membership_log`, CONSTRAINT `FK_civicrm_membership_log_status_id` FOREIGN KEY (`status_id`) REFERENCES `civicrm_membership_status` (`id`) ON DELETE CASCADE)]

The person is just trying to update their membership which has expired. The only entry in the membership_log for this membership_id is of a status id of 1. I noticed above that it doesn't seem to have status id as a field and maybe that is why the foreign key constraint is showing up.

Any help here?
    [to_string] => [db_error: message="DB Error: constraint violation" code=-3 mode=callback callback=CRM_Core_Error::handle prefix="" info="INSERT INTO civicrm_membership_log (membership_id , start_date , end_date , modified_id , modified_date , renewal_reminder_date ) VALUES ( 2376 ,  20071103 ,  20081102 ,  1425 ,  20090105 ,  00000 )  [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`aztea_civicrm/civicrm_membership_log`, CONSTRAINT `FK_civicrm_membership_log_status_id` FOREIGN KEY (`status_id`) REFERENCES `civicrm_membership_status` (`id`) ON DELETE CASCADE)]"]
---
Brett

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Foreign Key Constraint on Membership_Log Table
January 06, 2009, 11:00:08 am
It's a bit hard to tell what's going on w/o a backtrace - but it looks like the Membership Status Rules in your database might be in an unexpected state. Can you take a look at Administer CiviCRM >> CiviMember >> Membership Status rules on your site and compare them to the default set at:

http://drupal.demo.civicrm.org/civicrm/admin/member/membershipStatus?reset=1

... also, would help if you described specific steps that lead to the error (i.e. is this a constituent updating their membership through an online contribution / membership signup and renewal page? or is this someone on your staff "renewing" the membership from the contact Memberships tab? or ....??
Protect your investment in CiviCRM by  becoming a Member!

hintbw

  • I’m new here
  • *
  • Posts: 20
  • Karma: 1
    • AzTEA
Re: Foreign Key Constraint on Membership_Log Table
January 06, 2009, 12:00:41 pm
Dave - here's a backtrace

/home/aztea/public_html/current/sites/all/modules/civicrm/CRM/Core/Error.php, backtrace, 138
, handle,
/home/aztea/public_html/current/sites/all/modules/civicrm/packages/PEAR.php, call_user_func, 912
/home/aztea/public_html/current/sites/all/modules/civicrm/packages/DB.php, PEAR_Error, 966
/home/aztea/public_html/current/sites/all/modules/civicrm/packages/PEAR.php, DB_Error, 574
/home/aztea/public_html/current/sites/all/modules/civicrm/packages/DB/common.php, raiseError, 1903
/home/aztea/public_html/current/sites/all/modules/civicrm/packages/DB/mysql.php, raiseError, 898
/home/aztea/public_html/current/sites/all/modules/civicrm/packages/DB/mysql.php, mysqlRaiseError, 327
/home/aztea/public_html/current/sites/all/modules/civicrm/packages/DB/common.php, simpleQuery, 1216
/home/aztea/public_html/current/sites/all/modules/civicrm/packages/DB/DataObject.php, query, 2394
/home/aztea/public_html/current/sites/all/modules/civicrm/packages/DB/DataObject.php, _query, 1039
/home/aztea/public_html/current/sites/all/modules/civicrm/CRM/Core/DAO.php, insert, 279
/home/aztea/public_html/current/sites/all/modules/civicrm/CRM/Member/BAO/MembershipLog.php, save, 56
/home/aztea/public_html/current/sites/all/modules/civicrm/CRM/Member/BAO/Membership.php, add, 1242
/home/aztea/public_html/current/sites/all/modules/civicrm/CRM/Member/BAO/Membership.php, fixMembershipStatusBeforeRenew, 1029
/home/aztea/public_html/current/sites/all/modules/civicrm/CRM/Member/BAO/Membership.php, renewMembership, 941
/home/aztea/public_html/current/sites/all/modules/civicrm/CRM/Contribute/Form/Contribution/Confirm.php, postProcessMembership, 463
/home/aztea/public_html/current/sites/all/modules/civicrm/CRM/Core/Form.php, postProcess, 247
/home/aztea/public_html/current/sites/all/modules/civicrm/CRM/Core/StateMachine.php, mainProcess, 166
/home/aztea/public_html/current/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Next.php, perform, 63
/home/aztea/public_html/current/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php, perform, 203
/home/aztea/public_html/current/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php, handle, 103
/home/aztea/public_html/current/sites/all/modules/civicrm/CRM/Core/Controller.php, handle, 232
/home/aztea/public_html/current/sites/all/modules/civicrm/CRM/Core/Invoke.php, run, 197
/home/aztea/public_html/current/sites/all/modules/civicrm/drupal/civicrm.module, invoke, 315
, civicrm_invoke,
/home/aztea/public_html/current/includes/menu.inc, call_user_func_array, 348
/home/aztea/public_html/current/index.php, menu_execute_active_handler, 18

I'll also attach a brief screenshot of my membership status rules, but I'll also check it against the set you recommended. I'll also add that he hit this error when going into renew his membership via a contribution page. I tried going in with my account and can renew my membership just fine, however he always encounters the error. Any additional ideas?
---
Brett

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Foreign Key Constraint on Membership_Log Table
January 06, 2009, 01:32:43 pm
Looks like the code is not able to assign a valid membership status to this membership based on your status rule configuration. I see you've disabled the 'Grace' status (which in the default rules covers the period from End Date thru End Date + 1 month). I can't tell how you've configured the rule for 'Expired' - but I can tell it's different from the default rule (which is End Date + 1 month and onward).

I'd recommend reviewing your active rules and making sure that the range of "membership conditions" is covered by your set of rules.

If my theory is correct, I'll look into adding some improved error trapping for the situation - so keep us posted.
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMember (Moderator: Deepak Srivastava) »
  • Foreign Key Constraint on Membership_Log Table

This forum was archived on 2017-11-26.