Answers.Body: <p>Looks like civicrm_activity.parent_id is pointing to orphan records. You will need to fix the orphan records and then run the upgrade. You can use <a href="https://gist.github.com/pradpnayak/6631f3c1bcafe0899432ea89206826af" rel="nofollow noreferrer">MySQL commands</a> to fix the records.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-14T18:21:20.160Z
Answers.LastActivityDate: 2023-11-14T18:21:20.160Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>DB error when upgrading Civi from 5.60.0 to 5.67.0</p>
  <pre><code>Type    DB_Error
  Code    -3
  Message DB Error: constraint violation
  Mode    16
  UserInfo    ALTER TABLE `civicrm_activity` ADD CONSTRAINT `FK_civicrm_activity_parent_id` FOREIGN KEY (`parent_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE SET NULL [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`d9_civicrm`.`#sql-48a_21833f`, CONSTRAINT `FK_civicrm_activity_parent_id` FOREIGN KEY (`parent_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE SET NULL)]
  DebugInfo   ALTER TABLE `civicrm_activity` ADD CONSTRAINT `FK_civicrm_activity_parent_id` FOREIGN KEY (`parent_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE SET NULL [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`d9_civicrm`.`#sql-48a_21833f`, CONSTRAINT `FK_civicrm_activity_parent_id` FOREIGN KEY (`parent_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE SET NULL)]
  </code></pre>
  
Tags: <upgrade>
Title: CiviCRM upgrade issue 5.67.0
ThreadText: # CiviCRM upgrade issue 5.67.0
  
  (Asked by: username_0 on 2023-11-14)
  
  DB error when upgrading Civi from 5.60.0 to 5.67.0
  Type    DB_Error
  Code    -3
  Message DB Error: constraint violation
  Mode    16
  UserInfo    ALTER TABLE `civicrm_activity` ADD CONSTRAINT `FK_civicrm_activity_parent_id` FOREIGN KEY (`parent_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE SET NULL [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`d9_civicrm`.`#sql-48a_21833f`, CONSTRAINT `FK_civicrm_activity_parent_id` FOREIGN KEY (`parent_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE SET NULL)]
  DebugInfo   ALTER TABLE `civicrm_activity` ADD CONSTRAINT `FK_civicrm_activity_parent_id` FOREIGN KEY (`parent_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE SET NULL [nativecode=1452 ** Cannot add or update a child row: a foreign key constraint fails (`d9_civicrm`.`#sql-48a_21833f`, CONSTRAINT `FK_civicrm_activity_parent_id` FOREIGN KEY (`parent_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE SET NULL)]
  
  **Tags:** upgrade
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-11-14. Score: 1
  
  Looks like civicrm\_activity.parent\_id is pointing to orphan records. You will need to fix the orphan records and then run the upgrade. You can use [MySQL commands](https://gist.github.com/pradpnayak/6631f3c1bcafe0899432ea89206826af) to fix the records.
  
  
  ---
  
  