Answers.Body: <p>The problem here was the Extension Extended Reports - however it's possible that you have a different extension causing the problem.</p>
  <p>In 5.47.0 CiviGrant component was transferred to an extension. You need to upgrade to at least the 5.12.1 version of CiviCRM Extended reports.</p>
  <p>If you have hit this you should be able to finish the upgrade tasks manually:</p>
  <p>You will need to Flush Caches
  Rebuild all triggers (If you haven't turned them off for the upgrade)
  and force a rebuild of the CiviCRM Asset Cache</p>
  <p>To do via the UI you will want to clear caches and toggle logging on and off - If you didn't turn it off for the upgrade.</p>
  <p>The PHP to do this if you prefer can be found at <a href="https://github.com/civicrm/civicrm-core/blob/1754e1752eb8e516ec846a438005f6fcb55be247/CRM/Upgrade/Form.php#L818" rel="noreferrer">https://github.com/civicrm/civicrm-core/blob/1754e1752eb8e516ec846a438005f6fcb55be247/CRM/Upgrade/Form.php#L818</a></p>
  <p>where you want to run everything until the end of that method.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-11T04:46:34.713Z
Answers.Text: thanks for this great answer.  What I did that was worked was 1.  Go to /civicrm/admin/extensions?reset=1&action=browse and upgraded Extended Reports.  2.  I used cv php:eval to run line 818. 3. I ran cv flush 4. I put lines 824-828 in a script and ran that with cv php:script. You might be able to just use all of the lines between 818-828 in one script and save some steps.  Hope this helps.  -Josh
Answers.UserDisplayName: Josh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-04T17:27:54.800Z
Answers.Text: Thanks,
  How can I tell if it ran successfully?
  I rant cv php:script path/to/script something ran but I did not get any output or errors, So I assume it went through successfully.
Answers.UserDisplayName: Netzih
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-11T00:09:49.100Z
Answers.LastActivityDate: 2022-03-11T00:09:49.100Z
Answers.UserDisplayName: Luke Stewart
Answers.Body: <p>There few other alternate approaches to proceed with Civi 5.47 upgrade if you have an Extended report extension enabled</p>
  <ol>
  <li><p>Upgrade CiviCRM to 5.46.2 -&gt; Upgrade Extended report to 5.13 -&gt; Upgrade CiviCRM to 5.47.1</p>
  </li>
  <li><p>Upgrade Extended report to 5.13 -&gt; Upgrade CiviCRM to 5.47.1</p>
  </li>
  <li><p>Comment the <a href="https://github.com/civicrm/civicrm-core/blob/5.47/CRM/Upgrade/Incremental/php/FiveFortySeven.php#L127" rel="nofollow noreferrer">line 127 in CRM/Upgrade/Incremental/php/FiveFortySeven.php</a> -&gt; Upgrade CiviCRM to 5.47.1 -&gt; Upgrade Extended report to 5.13</p>
  </li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-13T19:55:41.953Z
Answers.Text: Option 3 - Won't you want to follow up afterwards and execute that sql to remove it out of the component list?
Answers.UserDisplayName: Luke Stewart
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-13T23:14:45.033Z
Answers.Text: yes but that shouldn't cause any problem if stays in
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-24T18:46:04.677Z
Answers.Text: running into the same errors when update extensions along with 5.30.3 upgrade.   A real mess so far as it is not clear which extensions have the problems.  
  API error: DB Error: constraint violation on ReportTemplate.create
Answers.UserDisplayName: Dave T
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-24T19:46:44.200Z
Answers.Text: same error upgrading Mosaico before Civi upgrade
Answers.UserDisplayName: Dave T
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-26T13:37:40.677Z
Answers.Text: You need upgrade extended report extension
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-26T21:16:57.893Z
Answers.Text: instructions here - https://lab.civicrm.org/dev/core/-/issues/3101#note_77418
Answers.UserDisplayName: Dave T
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-27T01:54:37.107Z
Answers.Text: Like I said, you needed to upgrade extended report extension
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-11T11:20:50.640Z
Answers.LastActivityDate: 2022-03-11T11:33:20.947Z
Answers.LastEditDate: 2022-03-11T11:33:20.947Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>On running an upgrade to 5.47.1 I get the following</p>
  <p>[Error: Finish core DB updates 5.47.1]
  Exception: &quot;API error: DB Error: constraint violation on ReportTemplate.create&quot;</p>
  <p>Partial stacktrace</p>
  <pre><code>#0 [civicrm-root]/CRM/Core/ManagedEntities.php(375): CRM_Core_ManagedEntities-&gt;onApiError(&quot;ReportTemplate&quot;, &quot;create&quot;, (Array:8), (Array:6))
  #1 [civicrm-root]/CRM/Core/ManagedEntities.php(187): CRM_Core_ManagedEntities-&gt;updateExistingEntity(Object(CRM_Core_DAO_Managed), (Array:10))
  #2 [civicrm-root]/CRM/Core/ManagedEntities.php(167): CRM_Core_ManagedEntities-&gt;reconcileEnabledModule(&quot;nz.co.fuzion.extendedreport&quot;)
  #3 [civicrm-root]/CRM/Core/ManagedEntities.php(128): CRM_Core_ManagedEntities-&gt;reconcileEnabledModules()
  #4 [civicrm-root]/CRM/Core/Invoke.php(413): CRM_Core_ManagedEntities-&gt;reconcile()
  #5 [civicrm-root]/CRM/Upgrade/Form.php(818): CRM_Core_Invoke::rebuildMenuAndCaches(FALSE, TRUE)
  #6 [civicrm-root]/CRM/Queue/Task.php(73): CRM_Upgrade_Form::doCoreFinish(Object(CRM_Queue_TaskContext), &quot;5.47.1&quot;, &quot;5.47.1&quot;, &quot;5.47.1&quot;, &quot;/tmp/civicrm-post-upgradeRgUuuC&quot;)
  #7 [civicrm-root]/CRM/Queue/Runner.php(215): CRM_Queue_Task-&gt;run(Object(CRM_Queue_TaskContext))
  #8 [civicrm-root]/CRM/Queue/Page/AJAX.php(36): CRM_Queue_Runner-&gt;runNext(TRUE)
  #9 [civicrm-root]/CRM/Queue/ErrorPolicy.php(89): CRM_Queue_Page_AJAX::{closure}()
  #10 [civicrm-root]/CRM/Queue/Page/AJAX.php(38): CRM_Queue_ErrorPolicy-&gt;call(Object(Closure))
  #11 [civicrm-root]/CRM/Core/Invoke.php(285): CRM_Queue_Page_AJAX::runNext()
  #12 [civicrm-root]/CRM/Core/Invoke.php(69): CRM_Core_Invoke::runItem((Array:13))
  #13 [civicrm-root]/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:5))
  #14 [civicrm-root]/civicrm/src/Civicrm.php(88): CRM_Core_Invoke::invoke((Array:5))
  #15 /civicrm/src/Controller/CivicrmController.php(80): Drupal\civicrm\Civicrm-&gt;invoke((Array:5))
  #16 [internal function](): Drupal\civicrm\Controller\CivicrmController-&gt;main((Array:5), &quot;queue:ajax:runNext&quot;)
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-03-11T15:34:57.560Z
Comments.Text: Thanks. I was planning on posting about this over the weekend. Now I have some solutions to try on the site I'm working to upgrade.
Comments.UserDisplayName: Jenni Simonis
Tags: <extension><upgrade>
Title: Upgrade to 5.47.x fails with error: Exception: "API error: DB Error: constraint violation on ReportTemplate.create"
ThreadText: # Upgrade to 5.47.x fails with error: Exception: "API error: DB Error: constraint violation on ReportTemplate.create"
  
  (Asked by: username_0 on 2022-03-11)
  
  On running an upgrade to 5.47.1 I get the following
  [Error: Finish core DB updates 5.47.1]
  Exception: "API error: DB Error: constraint violation on ReportTemplate.create"
  Partial stacktrace
  #0 [civicrm-root]/CRM/Core/ManagedEntities.php(375): CRM_Core_ManagedEntities->onApiError("ReportTemplate", "create", (Array:8), (Array:6))
  #1 [civicrm-root]/CRM/Core/ManagedEntities.php(187): CRM_Core_ManagedEntities->updateExistingEntity(Object(CRM_Core_DAO_Managed), (Array:10))
  #2 [civicrm-root]/CRM/Core/ManagedEntities.php(167): CRM_Core_ManagedEntities->reconcileEnabledModule("nz.co.fuzion.extendedreport")
  #3 [civicrm-root]/CRM/Core/ManagedEntities.php(128): CRM_Core_ManagedEntities->reconcileEnabledModules()
  #4 [civicrm-root]/CRM/Core/Invoke.php(413): CRM_Core_ManagedEntities->reconcile()
  #5 [civicrm-root]/CRM/Upgrade/Form.php(818): CRM_Core_Invoke::rebuildMenuAndCaches(FALSE, TRUE)
  #6 [civicrm-root]/CRM/Queue/Task.php(73): CRM_Upgrade_Form::doCoreFinish(Object(CRM_Queue_TaskContext), "5.47.1", "5.47.1", "5.47.1", "/tmp/civicrm-post-upgradeRgUuuC")
  #7 [civicrm-root]/CRM/Queue/Runner.php(215): CRM_Queue_Task->run(Object(CRM_Queue_TaskContext))
  #8 [civicrm-root]/CRM/Queue/Page/AJAX.php(36): CRM_Queue_Runner->runNext(TRUE)
  #9 [civicrm-root]/CRM/Queue/ErrorPolicy.php(89): CRM_Queue_Page_AJAX::{closure}()
  #10 [civicrm-root]/CRM/Queue/Page/AJAX.php(38): CRM_Queue_ErrorPolicy->call(Object(Closure))
  #11 [civicrm-root]/CRM/Core/Invoke.php(285): CRM_Queue_Page_AJAX::runNext()
  #12 [civicrm-root]/CRM/Core/Invoke.php(69): CRM_Core_Invoke::runItem((Array:13))
  #13 [civicrm-root]/CRM/Core/Invoke.php(36): CRM_Core_Invoke::_invoke((Array:5))
  #14 [civicrm-root]/civicrm/src/Civicrm.php(88): CRM_Core_Invoke::invoke((Array:5))
  #15 /civicrm/src/Controller/CivicrmController.php(80): Drupal\civicrm\Civicrm->invoke((Array:5))
  #16 [internal function](): Drupal\civicrm\Controller\CivicrmController->main((Array:5), "queue:ajax:runNext")
  
  **Tags:** extension, upgrade
  
  > **Comments:**
  > **username_1**: Thanks. I was planning on posting about this over the weekend. Now I have some solutions to try on the site I'm working to upgrade.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2022-03-11. Score: 10
  
  The problem here was the Extension Extended Reports - however it's possible that you have a different extension causing the problem.
  
  In 5.47.0 CiviGrant component was transferred to an extension. You need to upgrade to at least the 5.12.1 version of CiviCRM Extended reports.
  
  If you have hit this you should be able to finish the upgrade tasks manually:
  
  You will need to Flush Caches
  Rebuild all triggers (If you haven't turned them off for the upgrade)
  and force a rebuild of the CiviCRM Asset Cache
  
  To do via the UI you will want to clear caches and toggle logging on and off - If you didn't turn it off for the upgrade.
  
  The PHP to do this if you prefer can be found at <https://github.com/civicrm/civicrm-core/blob/1754e1752eb8e516ec846a438005f6fcb55be247/CRM/Upgrade/Form.php#L818>
  
  where you want to run everything until the end of that method.
  
  > **Comments:**
  > **username_2**: thanks for this great answer.  What I did that was worked was 1.  Go to /civicrm/admin/extensions?reset=1&action=browse and upgraded Extended Reports.  2.  I used cv php:eval to run line 818. 3. I ran cv flush 4. I put lines 824-828 in a script and ran that with cv php:script. You might be able to just use all of the lines between 818-828 in one script and save some steps.  Hope this helps.  -username_2  
  > **username_3**: Thanks, How can I tell if it ran successfully? I rant cv php:script path/to/script something ran but I did not get any output or errors, So I assume it went through successfully.  
  
  ---
  
  ### Answer by username_4 on 2022-03-11. Score: 2
  
  There few other alternate approaches to proceed with Civi 5.47 upgrade if you have an Extended report extension enabled
  
  1. Upgrade CiviCRM to 5.46.2 -> Upgrade Extended report to 5.13 -> Upgrade CiviCRM to 5.47.1
  2. Upgrade Extended report to 5.13 -> Upgrade CiviCRM to 5.47.1
  3. Comment the [line 127 in CRM/Upgrade/Incremental/php/FiveFortySeven.php](https://github.com/civicrm/civicrm-core/blob/5.47/CRM/Upgrade/Incremental/php/FiveFortySeven.php#L127) -> Upgrade CiviCRM to 5.47.1 -> Upgrade Extended report to 5.13
  
  > **Comments:**
  > **username_0**: Option 3 - Won't you want to follow up afterwards and execute that sql to remove it out of the component list?  
  > **username_4**: yes but that shouldn't cause any problem if stays in  
  > **username_5**: running into the same errors when update extensions along with 5.30.3 upgrade.   A real mess so far as it is not clear which extensions have the problems.   API error: DB Error: constraint violation on ReportTemplate.create  
  > **username_5**: same error upgrading Mosaico before Civi upgrade  
  > **username_4**: You need upgrade extended report extension  
  > **username_5**: instructions here - https://lab.civicrm.org/dev/core/-/issues/3101#note_77418  
  > **username_4**: Like I said, you needed to upgrade extended report extension  
  
  ---
  
  