1

I am trying to upgrade CiviCRM from 4.2.0 to 5.2.2 and am getting the error below. Whenever the upgrade runs it stops at DB to 4.3.alpha1 and throws up the error. Am on Drupal 7.

[Error: Upgrade DB to 4.3.alpha1]
ERROR FIELD ERROR VALUE
Type    DB_Error
Code    -3
Message DB Error: constraint violation
Mode    16
UserInfo    INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' , 12985 , 'civicrm_contact,12985' , 2 , 20211206190550 ) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`fwcivi`.`civicrm_log`, CONSTRAINT `FK_civicrm_log_modified_id` FOREIGN KEY (`modified_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
DebugInfo   INSERT INTO civicrm_log (entity_table , entity_id , data , modified_id , modified_date ) VALUES ('civicrm_contact' , 12985 , 'civicrm_contact,12985' , 2 , 20211206190550 ) [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`fwcivi`.`civicrm_log`, CONSTRAINT `FK_civicrm_log_modified_id` FOREIGN KEY (`modified_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE)]
PEAR_Exception: DB Error: constraint violation in /Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/PEAR.php on line 921
- DB_Error: DB Error: constraint violation in unknown on line unknown
Exception trace
#   Function    Location
0   CRM_Core_Error::exceptionHandler(Object(DB_Error))  /Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/PEAR.php:921
1   PEAR_Error->__construct('DB Error: constr…', -3, 16, Array, 'INSERT INTO civi…')    /Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/DB.php:984
2   DB_Error->__construct(-3, 16, Array, 'INSERT INTO civi…')   /Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/PEAR.php:575
3   PEAR->_raiseError(Object(DB_mysqli), null, -3, 16, Array, 'INSERT INTO civi…', 'DB_Error', true)    /Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/PEAR.php:223
4   PEAR->__call('raiseError', Array)   /Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/DB/common.php:1905
5   DB_common->raiseError(-3, null, null, 'INSERT INTO civi…', '1452 ** Cannot a…') /Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/DB/mysqli.php:933
6   DB_mysqli->mysqliRaiseError()   /Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/DB/mysqli.php:403
7   DB_mysqli->simpleQuery('INSERT INTO civi…') /Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/DB/common.php:1216
8   DB_common->query('INSERT INTO civi…')   /Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/DB/DataObject.php:2443
9   DB_DataObject->_query('INSERT INTO civi…')  /Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/DB/DataObject.php:1068
10  DB_DataObject->insert() /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Core/DAO.php:548
11  CRM_Core_DAO->save()    /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Core/BAO/Log.php:141
12  CRM_Core_BAO_Log::register(12985, 'civicrm_contact', 12985) /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Contact/BAO/Contact.php:218
13  CRM_Contact_BAO_Contact::add(Array) /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Upgrade/Incremental/php/FourThree.php:865
14  CRM_Upgrade_Incremental_php_FourThree->createDomainContacts()   /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Upgrade/Incremental/php/FourThree.php:128
15  CRM_Upgrade_Incremental_php_FourThree->setPostUpgradeMessage('<span class="bol…', '4.3.alpha1') /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Upgrade/Form.php:696
16  CRM_Upgrade_Form::doIncrementalUpgradeStep(Object(CRM_Queue_TaskContext), '4.3.alpha1', '4.2.0', '5.2.2', '/private/var/fol…')  /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Queue/Task.php:88
17  CRM_Queue_Task->run(Object(CRM_Queue_TaskContext))  /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Queue/Runner.php:214
18  CRM_Queue_Runner->runNext(true) /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php:52
19  CRM_Queue_Page_AJAX::{closure}()    /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Queue/ErrorPolicy.php:106
20  CRM_Queue_ErrorPolicy->call(Object(Closure))    /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Queue/Page/AJAX.php:54
21  CRM_Queue_Page_AJAX::runNext()  /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Core/Invoke.php:275
22  CRM_Core_Invoke::runItem(Array) /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Core/Invoke.php:84
23  CRM_Core_Invoke::_invoke(Array) /Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Core/Invoke.php:52
24  CRM_Core_Invoke::invoke(Array)  /Applications/MAMP/htdocs/sites/all/modules/civicrm/drupal/civicrm.module:445
25  civicrm_invoke('upgrade', 'queue', 'ajax', 'runNext')   /Applications/MAMP/htdocs/includes/menu.inc:527
26  menu_execute_active_handler()   /Applications/MAMP/htdocs/index.php:21
27  {main}   
1
1

The correct answer is already given, but I want to add some nuance.

This is actually addressed in the upgrade guide and is expected. As the guide states, it is not generally required to do intermediate version upgrades when making a bug version jump. The issue is that the current upgrader only supports versions starting from 4.7.

So, the issue is not the size of the version bump. You just have to get to 4.7 and then the current installer will work.

3

You're likely making too big of a jump in versions. I try to do it in small jumps, creating a backup after each try. Then I can easily revert to the last one if something breaks.

2
  • 1
    Hi Jenni You were so right. All I did was make the small jumps as you advised and I am all smiles again. Thank you so so much really appreciate your advice ;)
    – EmmyL
    Dec 7 '21 at 16:47
  • Not a problem. I've run into the issue enough times that this has become my standard if I'm upgrading very far. Dec 8 '21 at 5:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.