Answers.Body: <p>If you are on a recent version of CiviCRM you can run the Managed.reconcile api through the api explorer - in this instance I'm running it to reconcile extended reports - you can do all extensions at once, or one or two at a time. You are looking to see which extension hits an error while reconciling - the extension with the issue might not be the one that you are experiencing the error on.</p>
  <p><a href="https://i.sstatic.net/8tloA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/8tloA.png" alt="Managed_reconcile" /></a></p>
  <p>Generally all declared managed entities should have an entry in the <code>civicrm_managed</code> table - eg for this entity <a href="https://github.com/eileenmcnaughton/nz.co.fuzion.extendedreport/blob/21b4be5d01384caf73ffe9c9e92f187d8f6cf84d/CRM/Extendedreport/Form/Report/RelationshipExtended.mgd.php" rel="nofollow noreferrer">https://github.com/eileenmcnaughton/nz.co.fuzion.extendedreport/blob/21b4be5d01384caf73ffe9c9e92f187d8f6cf84d/CRM/Extendedreport/Form/Report/RelationshipExtended.mgd.php</a> I can find a row in civicrm_managed and the entity_id matches the id of the OptionValue in civicrm_option_value (note that <code>ReportTemplate</code> is a v3 api alias for <code>OptionValue</code> - &amp; Extended report uses both at the moment as it is migrating to v4</p>
  <p><a href="https://i.sstatic.net/oAyte.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/oAyte.png" alt="entity" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-06T10:06:34.670Z
Answers.LastActivityDate: 2023-02-06T10:06:34.670Z
Answers.UserDisplayName: eileen
Answers.Body: <p>I found my culprit with this method. What I also figured out is that when I disabled Mosaico there were many references left in the database and I got the &quot;missing&quot; error message. Ultimately I deleted every reference in my civicrm database and then the errors went away and now my site is clean. It seems that uninstalling and then deleting a specific extension does not remove all references ? That said, thank you for the api4 method to uncover a culprit Eileen.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-12T15:23:13.713Z
Answers.LastActivityDate: 2023-03-12T15:23:13.713Z
Answers.UserDisplayName: barbaraec
Answers.Body: <p>I just ran into a similar error, is this related or a separate issue? In this case, the upgrade did not complete.
  <a href="https://i.sstatic.net/BjXx4.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/BjXx4.png" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-07T08:08:58.273Z
Answers.Text: Looks exactly the same problem to me.
Answers.UserDisplayName: Andy Clark
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-20T00:15:56.003Z
Answers.Text: Keith actually at that stage of the upgrade, the upgrade *did* complete, but it is having a hard time loading the final update complete page due to the extension conflict. Check your civicrm_domain table in your MySQL and see what the version is.  If it is correct, you are OK.  Update the extension all should be well.
Answers.UserDisplayName: CiviTeacher
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-07T01:32:20.720Z
Answers.LastActivityDate: 2023-02-07T01:32:20.720Z
Answers.UserDisplayName: Keith Webb
Answers.Body: <p>Thank you for this. Fixed by disabling the Reports Plus extension (v 2.6.2) which we were attempting to use the same time as Extended Reports (v. 5.21) on CiviCRM 5.58.1</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-20T00:20:14.023Z
Answers.LastActivityDate: 2023-02-20T00:20:14.023Z
Answers.UserDisplayName: CiviTeacher
Answers.Body: <p>Thanks to Eileen, who said 'Generally you see that when there is an entry in civicrm_option_value but not in civicrm_managed for a report being registered by the extension &amp; the site will keep getting the error until it is fixed'.  The culprit seemed to be an entry from the ReportPlus extension in civicrm_option_value that remained after I uninstalled this extension. This record had the label 'Activity Detail Plus'</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-07T01:22:51.597Z
Answers.Text: Did you just delete the record 'Activity Detail Plus' and the error went away?
Answers.UserDisplayName: Keith Webb
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-07T08:08:25.673Z
Answers.Text: Neither of the 2 systems that had the extension were using any of the ReportPlus reports so I used uninstalling as a quick way of identifying mismatched items.  In both cases it was this 'Activity Detail Plus' record which I deleted.  I reran the 5.57.3 upgrade on one system and it then worked.  On the other system I believe that although the upgrade failed on the last step, it all worked & there's no damage.  If you didn't want to remove ReportPlus it would be worth deleting this record & retrying.
Answers.UserDisplayName: Andy Clark
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-06T09:27:28.540Z
Answers.LastActivityDate: 2023-02-06T10:12:33.873Z
Answers.LastEditDate: 2023-02-06T10:12:33.873Z
Answers.UserDisplayName: Andy Clark
Body: <p>I've had the above error on a couple of upgrades recently - one was an upgrade to 5.57.3 on a test system and another when upgrading the 'Report Plus' extension (see below)<a href="https://i.sstatic.net/nSGUI.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/nSGUI.png" alt="enter image description here" /></a>. In both cases the upgrade stopped but appeared to be successful. I looked at the code (attached) but couldn't figure out what the problem is. Both were Drupal 7 systems.  Can anyone help (please) ?</p>
  
Tags: <drupal><upgrade>
Title: Upgrade error = API error: Value already exists in the database on ReportTemplate.create
ThreadText: # Upgrade error = API error: Value already exists in the database on ReportTemplate.create
  
  (Asked by: username_0 on 2023-02-02)
  
  I've had the above error on a couple of upgrades recently - one was an upgrade to 5.57.3 on a test system and another when upgrading the 'Report Plus' extension (see below)[![enter image description here](https://i.sstatic.net/nSGUI.png)](https://i.sstatic.net/nSGUI.png). In both cases the upgrade stopped but appeared to be successful. I looked at the code (attached) but couldn't figure out what the problem is. Both were Drupal 7 systems. Can anyone help (please) ?
  
  **Tags:** drupal, upgrade
  
  
  ---
  
  ## 5 answers
  
  ### Answer by username_1 on 2023-02-06. Score: 2 | Accepted answer
  
  If you are on a recent version of CiviCRM you can run the Managed.reconcile api through the api explorer - in this instance I'm running it to reconcile extended reports - you can do all extensions at once, or one or two at a time. You are looking to see which extension hits an error while reconciling - the extension with the issue might not be the one that you are experiencing the error on.
  
  [![Managed_reconcile](https://i.sstatic.net/8tloA.png)](https://i.sstatic.net/8tloA.png)
  
  Generally all declared managed entities should have an entry in the `civicrm_managed` table - eg for this entity <https://github.com/username_1mcnaughton/nz.co.fuzion.extendedreport/blob/21b4be5d01384caf73ffe9c9e92f187d8f6cf84d/CRM/Extendedreport/Form/Report/RelationshipExtended.mgd.php> I can find a row in civicrm\_managed and the entity\_id matches the id of the OptionValue in civicrm\_option\_value (note that `ReportTemplate` is a v3 api alias for `OptionValue` - & Extended report uses both at the moment as it is migrating to v4
  
  [![entity](https://i.sstatic.net/oAyte.png)](https://i.sstatic.net/oAyte.png)
  
  
  ---
  
  ### Answer by username_2 on 2023-03-12. Score: 0
  
  I found my culprit with this method. What I also figured out is that when I disabled Mosaico there were many references left in the database and I got the "missing" error message. Ultimately I deleted every reference in my civicrm database and then the errors went away and now my site is clean. It seems that uninstalling and then deleting a specific extension does not remove all references ? That said, thank you for the api4 method to uncover a culprit Eileen.
  
  
  ---
  
  ### Answer by username_3 on 2023-02-07. Score: 0
  
  I just ran into a similar error, is this related or a separate issue? In this case, the upgrade did not complete.
  [![enter image description here](https://i.sstatic.net/BjXx4.png)](https://i.sstatic.net/BjXx4.png)
  
  > **Comments:**
  > **username_0**: Looks exactly the same problem to me.  
  > **username_4**: Keith actually at that stage of the upgrade, the upgrade *did* complete, but it is having a hard time loading the final update complete page due to the extension conflict. Check your civicrm_domain table in your MySQL and see what the version is.  If it is correct, you are OK.  Update the extension all should be well.  
  
  ---
  
  ### Answer by username_4 on 2023-02-20. Score: 0
  
  Thank you for this. Fixed by disabling the Reports Plus extension (v 2.6.2) which we were attempting to use the same time as Extended Reports (v. 5.21) on CiviCRM 5.58.1
  
  
  ---
  
  ### Answer by username_0 on 2023-02-06. Score: 0
  
  Thanks to Eileen, who said 'Generally you see that when there is an entry in civicrm\_option\_value but not in civicrm\_managed for a report being registered by the extension & the site will keep getting the error until it is fixed'. The culprit seemed to be an entry from the ReportPlus extension in civicrm\_option\_value that remained after I uninstalled this extension. This record had the label 'Activity Detail Plus'
  
  > **Comments:**
  > **username_3**: Did you just delete the record 'Activity Detail Plus' and the error went away?  
  > **username_0**: Neither of the 2 systems that had the extension were using any of the ReportPlus reports so I used uninstalling as a quick way of identifying mismatched items.  In both cases it was this 'Activity Detail Plus' record which I deleted.  I reran the 5.57.3 upgrade on one system and it then worked.  On the other system I believe that although the upgrade failed on the last step, it all worked & there's no damage.  If you didn't want to remove ReportPlus it would be worth deleting this record & retrying.  
  
  ---
  
  