CMJ Integrity Check reports "The custom field context is not correctly associated with existing issue types."

Symptoms:

Inconsistent object for custom field context is reported by Integrity Check with description: "The custom field context is not correctly associated with existing issue types.".

Non user is able to save any changes to the custom field context (e.g. associated issue types, projects, etc.) from the UI.

Similar logs are observed: 

[c.a.j.i.fields.config.FieldConfigSchemeImpl]There is not exactly one config for this scheme (10000). Configs are {}.

Cause:

The mapping between issue types and custom field scheme is broken on DB level. The table FIELDCONFIGSCHEMEISSUETYPE contains one row for each issue type associated with a context or one single row with ISSUETYPE=null if associated with all. If no rows are found for the problematic context proceed with the proposed resolution.


Resolution:

Execute the following SQL script replacing all IDs with the one from your instance. Afterwards, refresh JIRA’s internal caches for this change to be picked up – you can do that by going to CMJ’s Advanced page and clicking the Clear caches button.

INSERT INTO FIELDCONFIGSCHEMEISSUETYPE (ID, ISSUETYPE, FIELDCONFIGSCHEME, FIELDCONFIGURATION )
	VALUES ('SCHEME_ID', null, 'SCHEME_ID', 'CONFIG_ID')

Where SCHEME_ID and CONFIG_ID are the custom field context and configuration IDs that could be found with the following SQL script:

SELECT * FROM FIELDCONFIGSCHEME WHERE FIELDID='CUSTOMFIELD_ID'
SELECT * FROM FIELDCONFIGURATION WHERE FIELDID='CUSTOMFIELD_ID'

Where CUSTOMFIELD_ID is the ID of the custom field.