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 problems upgrading from 1.7 to 2.0
Pages: [1]

Author Topic: Foreign key problems upgrading from 1.7 to 2.0  (Read 1753 times)

tvaughan

  • Guest
Foreign key problems upgrading from 1.7 to 2.0
April 15, 2008, 04:14:13 am
I'm trying to get a database upgraded from 1.7 to 2.0.  Currently the 1.7 database is running on MySQL 4.1 and all the tables are MyISAM (not sure why).

I've recreated the empty 1.7 database (with tables as InnoDB) on my development machine running XAMPP (MySQL 5, PHP5) and have tried to import the 1.7 data into it.  However, I get this error:

Code: [Select]
#1452 - Cannot add or update a child row: a foreign key constraint fails (`civicrm/civicrm_address`, CONSTRAINT `FK_civicrm_address_location_id` FOREIGN KEY (`location_id`) REFERENCES `civicrm_location` (`id`))
I don't know a huge amount about MySQL but I'm wondering whether this is because of the move to InnoDB from MyISAM?

I've managed to get CiviCRM 2.0 running fine apart from this step so any assistance would be appreciated!

Deepak Srivastava

  • Moderator
  • Ask me questions
  • *****
  • Posts: 677
  • Karma: 65
Re: Foreign key problems upgrading from 1.7 to 2.0
April 15, 2008, 05:09:40 am
This confirms that you have successfully moved to InnoDB, which supports Foreign-Key unlike MyISAM.

And the error you got, is because of the Foreign-Key constraint not being satisfied. 

So when doing the import, disable the foreign key check, since otherwise data will not be imported.
And once you have got the data in your db, you can remove such entries. v2.0 Upgrade anyway takes care of such entries. 
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

tvaughan

  • Guest
Re: Foreign key problems upgrading from 1.7 to 2.0
April 15, 2008, 05:11:45 am
Thanks for the reply!  I'm doing this in PHPMyAdmin.  How should I disable the FK check there?

Deepak Srivastava

  • Moderator
  • Ask me questions
  • *****
  • Posts: 677
  • Karma: 65
Re: Foreign key problems upgrading from 1.7 to 2.0
April 15, 2008, 06:40:56 am
Include the following line at the top of the file, you importing :
Code: [Select]
SET FOREIGN_KEY_CHECKS = 0;

and the following, at the bottom of the file :
Code: [Select]
SET FOREIGN_KEY_CHECKS = 1;
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

tvaughan

  • Guest
Re: Foreign key problems upgrading from 1.7 to 2.0
April 15, 2008, 07:20:37 am
Thanks, that fixed it.  All seems to be running well (this is using XAMPP btw) so I'm ready to upgrade the main site, as soon as I find a decent host with MySQL 5 that is.

I'm getting FPDF errors but I'll create a new thread for that.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Foreign key problems upgrading from 1.7 to 2.0

This forum was archived on 2017-11-26.