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 at Step Four
Pages: [1]

Author Topic: Foreign Key error at Step Four  (Read 3237 times)

Peter Chauncy

  • I’m new here
  • *
  • Posts: 17
  • Karma: 2
Foreign Key error at Step Four
April 08, 2008, 01:06:21 pm
I am upgrading a 1.9 installation to 2.02.

I have completed the database rebuilding recommended in point 4 of the upgrade page.

I had a foreign key error at the Location upgrade step (Three), but was able to isolate it to a number of incorrect values in civicrm_address where the state_province_id didn't refer to a valid entry in the civicrm_state_province table.

At Step Four I get the following error:

Quote
Sorry. A non-recoverable error has occurred.

Database Error Code: Cannot add or update a child row: a foreign key constraint fails (`civicrm19fix/civicrm_activity`, CONSTRAINT `FK_civicrm_activity_phone_id` FOREIGN KEY (`phone_id`) REFERENCES `civicrm_phone` (`id`) ON DELETE SET NULL), 1452

I have looked for obvious errors in the civicrm_activity table and the civicrm_phone table. 


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: Foreign Key error at Step Four
April 08, 2008, 02:15:14 pm

can u ensure that all the phone id's that are referenced in civicrm_activity are present? seems like a few phone_ids have been deleted but still have a reference in civicrm_activity.

were u using innodb all the time? or were u on myisam for the 1.x series

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

Peter Chauncy

  • I’m new here
  • *
  • Posts: 17
  • Karma: 2
Re: Foreign Key error at Step Four
April 10, 2008, 04:10:28 am
Thanks for your quick reply.

All of the phone_id fields in the civicrm_activity table are "NULL". To confirm that is in the database civicrm19fix as it is at stage four of the upgrade.

All of the tables are innodb and have been since at least 1.7 (that's the earliest I have to hand). The database has been upgraded a number of times, since about 1.1 I think.  I recall having a problem with activities between 1.3 and 1.4.

Peter

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: Foreign Key error at Step Four
April 10, 2008, 11:40:42 am

can you email your database to deepak at webaccess dot co dot in

we'll take a look and get back 2 you

thanx

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

Andrew Perry

  • I post occasionally
  • **
  • Posts: 98
  • Karma: 1
  • Building empowering tools that comply with rules
    • Community Builders Australia
  • CiviCRM version: 3.x, 4.x
  • CMS version: Joomla 1.0.x, 1.5.x -> Drupal 6.x, 7.x, WordPress
  • MySQL version: 5.1, 5.5, 5.6
  • PHP version: 5.2, 5.3, 5.4
Re: Foreign Key error at Step Four
April 15, 2008, 04:52:17 am
Any update on this?

We are having the same problem and aren't in a position to e-mail the db.

Any help appreciated.
Community Builders Australia Pty Ltd
www.communitybuilders.com.au

Deepak Srivastava

  • Moderator
  • Ask me questions
  • *****
  • Posts: 677
  • Karma: 65
Re: Foreign Key error at Step Four
April 16, 2008, 06:44:15 am
Two cases were found, in the db sent by Peter :

1. There were invalid entries in civicrm_phonecall, pointing to non-existing entry in civicrm_phone.

2. Few orphan entries in civicrm_option_value, pointing to non-existing activity records.   

Changes have been made to cleanup process (rev: 13997) - http://biryani.osuosl.org:8181/browse/CiviCRM/branches/v2.0/CRM/Upgrade/TwoZero/sql/cleanup.mysql?r1=13895&r2=13997
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Foreign Key error at Step Four

This forum was archived on 2017-11-26.