How to fix Integrity Check violation in reference to missing custom fields from the database [PS]


This article explains how to fix the Integrity Check violation in reference to missing custom fields from the database.

Problem

Deployment fails with an error “Unable to perform deployment: Unable to apply change 'type: removal, object: JiraCustomField#DMP 11. What metadata standard will be used?_com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons, target object: JiraConfigurationRoot#root, feature: customFields'“

Example code error

java.util.concurrent.ExecutionException: com.botronsoft.jira.rollout.snapshot.SnapshotOperationFailedException: Unable to perform deployment: Unable to apply change 'type: removal, object: JiraCustomField

This issue happens when restoring a configuration at the time of deployment from the source Jira to the target Jira, including the deletion of some custom fields that are still in the target environment but shouldn't be (as they have been deleted in production).

Solution

  1. Perform a cache refresh from CMJ's Advanced page.

  2. Execute the following DB query when replacing %MISSING_CUSTOM_FIELD_ID with the missing CustomFied ID from the Integrity Check for Jira:

    SELECT * FROM AO_54307E_VIEWPORTFIELD as field inner join AO_54307E_VIEWPORTFORM as form ON field.form_id = form.id where field_id = '%MISSING_CUSTOM_FIELD_ID'
  3. With the above-mentioned DB query, you can have a better view of the request types that have reference to the missing custom fields, if there are any. 

    After that, these references must be deleted from the AO_54307E_VIEWPORTFIELD table using their table id.


  4. Perform a database backup before performing an UPDATE or DELETE query.

  5. Run the below query, by replacing the placeholder with the database id of the custom field, which will delete the reference.

    DELETE FROM AO_54307E_VIEWPORTFIELD where ID =%

  6. After the database manipulation, a cache refresh from CMJ's Advanced page must be triggered. 

  7. After that, run the Integrity Check for Jira again.

    As a general precaution, before any direct database update, it is recommended to take a database backup. After the update, run a cache refresh for the changes to take effect (this can be done from CMJ's Advanced page)