Custom Field Type Namespace

Hey guys,

We’ve joined a couple of Jira plugins we were developing into a single one, and we’ve hit an issue with the custom fields namespacing =/

Like in Active Objects, we want to force the namespace key identifier to preserve and use the same data we have in the already running environments, like so

    <ao namespace="com.company.project.subprojecta" key="ao-module">
        <description>The module configuring the Active Objects service used by this plugin</description>
        <entity>com.company.project.subproject.ao.ColumnsInfo</entity>
        <entity>com.company.project.subproject.ao.View</entity>
    </ao>

The plugin-key is now com.company.project for resources - So, if we’d leave the namespace attribute out of the configuration, when installed in an already running environment, the current plugin configuration would not find the AO resources that were deployed previously, and we’d loose access to old data.

We want to do the same for the custom fields, since some of them were defined in the plugins we’ve joined now

    <customfield-type namespace="com.company.project.subprojecta" name="Custom Tag" i18n-name-key="custom-tag-cf.name" key="custom-tag-cf"
                      class="com.company.project.subprojecta.cf.CustomTagType">
        <description key="custom-tag-cf.description">Custom Tag Field</description>
        <resource name="view" type="velocity" location="templates/custom-tag.vm"/>
        <resource name="edit" type="velocity" location="templates/custom-tag.vm"/>
        <valid-searcher package="${atlassian.plugin.key}.subprojecta" key="custom-tag-searcher"/>
    </customfield-type>

Main changes we thought would make it work are

  • namespace=“com.company.project.subprojecta”
  • package="${atlassian.plugin.key}.subprojecta"

But when we log the on plugin install listener, we get this custom field type key:

Custom field key: com.company.project:custom-tag-cf, Custom Tag Field

Any help on how to force it would be appreciated - Also, we have access to database to migrate the data, just don’t know were to start :slight_smile:

Thanks in advance

For those who stumble with this issue, we’ve dealt with it through a SQL Script to update the PUBLIC.CUSTOMFIELDVALUE entries, for those custom fields.

Our solution for postgresql was something like

DO $$
	DECLARE
		oldrow record;
		newrow record;
		cfvrow record;
	BEGIN
		-- Find all old core fields on DB 
		FOR oldrow IN
			SELECT * FROM public.customfield where public.customfield.customfieldtypekey LIKE '%subprojecta%'
		LOOP
			RAISE NOTICE '% - %', oldrow.customfieldtypekey, oldrow.cfname;
			-- Find all new tcm fields on DB 
			FOR newrow IN
				SELECT * FROM public.customfield where public.customfield.customfieldtypekey LIKE 'com.company.project:%'
			LOOP
				IF newrow.cfname = oldrow.cfname THEN
					RAISE NOTICE '% - %', newrow.customfieldtypekey, newrow.cfname;
					FOR cfvrow IN
						SELECT * FROM public.customfieldvalue where public.customfieldvalue.customfield = oldrow.id OR public.customfieldvalue.customfield = newrow.id
					LOOP
						RAISE NOTICE 'Found value % - issue %, cf %', cfvrow.id, cfvrow.issue, newrow.cfname;
						RAISE NOTICE 'old % - new %', oldrow.id, newrow.id;
						UPDATE public.customfieldvalue SET customfield = newrow.id WHERE id = cfvrow.id;
						RAISE NOTICE 'updated: %', cfvrow.id;
					END LOOP;
					EXIT;
				ELSE
					CONTINUE;
				END IF;
			END LOOP;
		END LOOP;
	END;
$$;

:warning::warning::warning:
This was run through psql cli, remotely, with servers stopped and with previous DB backup. Gladly, it worked for our environments :grinning:

Hope this help anyone