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) »
  • error on upgrading from 2.1.1 to 2.1.2
Pages: [1]

Author Topic: error on upgrading from 2.1.1 to 2.1.2  (Read 2240 times)

rampkrm

  • Guest
error on upgrading from 2.1.1 to 2.1.2
November 24, 2008, 04:07:38 am
i tried to upgrade my drupal site's civicrm from 2.1.1 to 2.1.2. i got the fallowing error.

 
Code: [Select]
backTrace

 /sites/all/modules/civicrm/CRM/Core/Error.php, backtrace, 138
, handle,
 /sites/all/modules/civicrm/packages/PEAR.php, call_user_func, 912
 /sites/all/modules/civicrm/packages/DB.php, PEAR_Error, 966
 /sites/all/modules/civicrm/packages/PEAR.php, DB_Error, 574
 /sites/all/modules/civicrm/packages/DB/common.php, raiseError, 1903
 /sites/all/modules/civicrm/packages/DB/mysql.php, raiseError, 898
 /sites/all/modules/civicrm/packages/DB/mysql.php, mysqlRaiseError, 327
 /sites/all/modules/civicrm/packages/DB/common.php, simpleQuery, 1216
 /sites/all/modules/civicrm/CRM/Utils/File.php, query, 225
 /sites/all/modules/civicrm/CRM/Upgrade/Form.php, sourceSQLFile, 75
 /sites/all/modules/civicrm/CRM/Upgrade/TwoOne/Form/TwoOneTwo.php, source, 87
 /sites/all/modules/civicrm/CRM/Upgrade/TwoOne/Page/Upgrade.php, upgrade, 97
 /sites/all/modules/civicrm/CRM/Upgrade/TwoOne/Page/Upgrade.php, runTwoOneTwo, 43
 /sites/all/modules/civicrm/install/upgrade.php, run, 48
 /sites/all/modules/civicrm/install/upgrade.php, run, 51

unrecoverable error
    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 (`civicrm20/#sql-9ef_f4c`, CONSTRAINT `FK_civicrm_note_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`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_note`
    ADD CONSTRAINT `FK_civicrm_note_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE SET NULL [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`civicrm20/#sql-9ef_f4c`, CONSTRAINT `FK_civicrm_note_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE SET NULL)]
    [type] => DB_Error
    [user_info] => ALTER TABLE `civicrm_note`
    ADD CONSTRAINT `FK_civicrm_note_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE SET NULL [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`civicrm20/#sql-9ef_f4c`, CONSTRAINT `FK_civicrm_note_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`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_note`
    ADD CONSTRAINT `FK_civicrm_note_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE SET NULL [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`civicrm20/#sql-9ef_f4c`, CONSTRAINT `FK_civicrm_note_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE SET NULL)]"]
)


please let me know where i am wrong.

if it is a common error is there any patch for it?

here is my civicrm_note DB table structure
 
Code: [Select]
CREATE TABLE IF NOT EXISTS `civicrm_note` (
  `id` int(10) unsigned NOT NULL auto_increment COMMENT 'Note ID',
  `entity_table` varchar(64) collate utf8_unicode_ci NOT NULL COMMENT 'Name of table where item being referenced is stored.',
  `entity_id` int(10) unsigned NOT NULL COMMENT 'Foreign key to the referenced item.',
  `note` text collate utf8_unicode_ci COMMENT 'Note and/or Comment.',
  `contact_id` int(10) unsigned default NULL,
  `modified_date` date default NULL COMMENT 'When was this note last modified/edited',
  `subject` varchar(255) collate utf8_unicode_ci default NULL COMMENT 'subject of note description',
  PRIMARY KEY  (`id`),
  KEY `index_entity` (`entity_table`,`entity_id`),
  KEY `FK_civicrm_note_contact_id` (`contact_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=819 ;

before posting this i searched in forums and did not get correct solution for my problem.

[/code]
« Last Edit: November 24, 2008, 04:10:27 am by rampkrm »

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: error on upgrading from 2.1.1 to 2.1.2
November 24, 2008, 07:13:04 am

most likely your note field has some non-existent contact_id's and hence the FK error. Two potential solutions:

1. Write a query to find the bogus contact ids and set those values to null. (preferred method)

2. you can disable foreign key checks during the upgrade (add SET FOREIGN_KEY_CHECKS=0 to the beginning and FOREIGN_KEY_CHECKS=1 to the end of the sql file (CRM/Upgrade/TwoOne/sql/two_one_two.mysql)

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • error on upgrading from 2.1.1 to 2.1.2

This forum was archived on 2017-11-26.