Project import fails due to missing custom field options in Jira server

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

このページは、Jira でのデータベース操作に関連する情報を含みます。データベース操作はアトラシアンのサポート範囲に含まれないため、アトラシアン サポートでは、 このページに記載されている手順に対するサポートの提供を保証できません。この資料は情報提供のみを目的としているため、お客様自身の責任でご使用ください。

問題

Jira がインポート対象のカスタム フィールド オプションを見つけられないため、プロジェクトのインポートに失敗する。

プロジェクト インポート認証に次のようなエラーが表示される。

The custom field 'Select List' requires option 'One Two Three' for the import but it does not exist in the current JIRA instance.

診断

これは多くの場合、複数のオプションを持つ複数選択カスタム フィールドに影響します。

インポート先のインスタンスではカスタム フィールド オプションが利用可能です (このため、上記のエラー メッセージは少し誤解を招く内容となっています)。

問題は、エクスポート元のデータの側にあります。

原因

This problem can have a few causes.

  1. この問題の原因は、次の不具合です。  JRASERVER-63226 - Getting issue details... STATUS
  2. The values associated to the issues are associated to a different context than the issue's context

回避策

原因 1:

データベースの変更を行う場合は必ず事前にバックアップを取得してください。可能な場合は、まずステージング サーバーで SQL コマンドの変更、挿入、更新、または削除を行うようにします。

プロジェクト インポート後にエクスポート元のインスタンスが不要になる場合を除き、これらの変更を本番環境用のデータベースに直接行わないでください。エクスポート元のインスタンスの XML バックアップを使用してステージング サーバーをセットアップし、そこに変更を適用してからステージング サーバーのバックアップを新しく生成して、プロジェクト インポートに使用することをおすすめします。

この回避策は正常なプロジェクト インポートを実現 (インポート先のインスタンスにデータを正常にインポート) しますが、同時にステージング サーバーのカスタム フィールド オプションの関連付けを破壊します (後述)。このため、回避策の実施後はステージング サーバーのインスタンスを破棄することになります。

tip/resting Created with Sketch.

この回避策ではエクスポート元のインスタンスのコピーのデータベースを変更し、プロジェクト インポートのみを目的としてカスタム フィールド オプションの関連付けを "修正"します。

ステージング サーバーはすでに用意済みであることを想定しています。ここでは、次のデータベース変更を行います。

この例では、"Car" カスタム フィールドを使用します。自身のインスタンスの対象のカスタム フィールド名で "Car" を置き換えてください。

  1. カスタム フィールドの名前 (大文字 / 小文字が区別されます) を使用し、次のクエリを実行してカスタム フィールドの ID を特定します。

    select ID, cfname from customfield where cfname = 'Car';

    "ID" 列に表示されたカスタム フィールド ID を記録します。

  2. 次のクエリを実行して、対象のカスタム フィールドが使用しているカスタム フィールド構成を特定します (ステップ 1 で取得したカスタム フィールド ID で 10110 を置き換えます)。

    select distinct customfieldconfig from customfieldoption where customfield = 10110;
     
    // if you want to view more details, run this query instead:
    // select * from customfieldoption where customfield = 10110;

    "customfieldconfig" 列に表示されたフィールド構成 ID を記録します(各 ID は GUI から確認できるカスタム フィールドの異なるコンテキストとなり、1 つまたは複数のオプションを持ちます)。

  3. 次のクエリを実行して、カスタム フィールド構成スキームとカスタム フィールド構成の組み合わせを特定します (ステップ 1 で取得したカスタム フィールド ID で 10110 を置き換えます)。

    select cc.customfield, cc.PROJECT, fit.ISSUETYPE, fit.FIELDCONFIGSCHEME, fit.FIELDCONFIGURATION
    	from fieldconfigschemeissuetype fit inner join configurationcontext cc
    		on fit.fieldconfigscheme = cc.fieldconfigscheme where cc.customfield = 'customfield_10110';

    出力例と詳細説明:

    tip/resting Created with Sketch.

    上記の出力例では、次のことがわかります。

    - customfieldconfig10401 (クエリ #2) は fieldconfiguration10401 (クエリ #3) を参照し、これは fieldconfigscheme10401 (クエリ #3) を使用していること。Jira は 10401 を見つけられるため (クエリ #2)、これは正常な構成です (tick)

    customfieldconfig 10400 (クエリ #2) は fieldconfiguration 10400 (クエリ #3) を参照し、これは fieldconfigscheme 99999 (クエリ #3) を使用していること。Jira は 99999 を探し、10400 を見つけます (クエリ#2)。これがプロジェクト インポートに影響している問題となります。

  4. 次のクエリを実行して、10400 を 99999 で置き換えます (ステップ 1 で取得したカスタム フィールド ID で 10110 を置き換えます)。

    update customfieldoption set customfieldconfig = 99999 where customfield = 10110 and customfieldconfig = 10400;

    カスタム フィールドに既定値が設定されている場合、genericconfiguration テーブルに更新が必要です。

    update genericconfiguration set datakey=9999 where 
    datakey in (select distinct customfieldconfig from customfieldoption where customfield =(select ID from customfield where cfname = 'Car'));
    tip/resting Created with Sketch.

    -  関連付けの不整合をほかにも確認した場合、上述のパターンを使用し、それぞれについて Update クエリを実行します。

    -  クエリ #3 では、fieldconfiguration=fieldconfigscheme の場合、Update は不要です。

    - クエリ #3 ではクエリ #2 よりも多くのエントリが返される場合があります。フィールドに 1 つ以上のコンテキストが設定されていたり、オプションが設定されていない場合、これは正常な動作です。このようなエントリは無視してかまいません。

    クエリ #4 の Update により、ステージング サーバー (エクスポート元のインスタンスのデータを持つもの) に問題が発生します。Jira がさまざまな目的のために fieldconfiguration で 99999 を探した際に、異なる構成や存在しない構成を参照する可能性があるためです。これによってデータが破壊されますが、プロジェクト インポートではこの方向の参照を行わないため、プロジェクト インポートへの影響はありません。

  5. ステージング サーバーで新しい XML バックアップを生成します。

  6. バックアップを使用してインポート先のインスタンスでプロジェクトを復元し、完了したら破棄します。

サポート

上述のステップを実行する際にお困りのことがありましたら、サポート チケットを起票し、ステップ 1、2、3 の SQL クエリの実行結果を添付してください。

原因 2:

Edit the issues and select any valid values for the current context.

The SQL query below should display all the problematic issues

PostgreSQL クエリ
with contexts as (
select CF.cfname, FCS.configname, FCSIT.issuetype, CC.project, FCS.id 
from fieldconfigscheme FCS
join customfield CF on concat('customfield_',CF.id) = FCS.fieldid
join fieldconfigschemeissuetype FCSIT on FCSIT.fieldconfigscheme = FCS.id 
join configurationcontext CC on CC.fieldconfigscheme = FCS.id
where CF.cfname = 'Custom Cascade'
),
fullContext as (
select concat(concat(P.pkey,'-'),I.issuenum) as Issue, I.id as Issueid, C.cfname, C.configname, C.issuetype, C.project, C.id as ContextID
from jiraissue I
join project P on P.id = I.project 
join contexts C on I.issuetype = C.issuetype and I.project = C.project
),
typeContext as (
select concat(concat(P.pkey,'-'),I.issuenum) as Issue, I.id as Issueid, C.cfname, C.configname, C.issuetype, C.project, C.id as ContextID
from jiraissue I
join project P on P.id = I.project 
join contexts C on I.issuetype = C.issuetype and C.project is null
left join fullContext FC on FC.Issue = concat(concat(P.pkey,'-'),I.issuenum)
where FC.Issue is null
),
projectContext as (
select concat(concat(P.pkey,'-'),I.issuenum) as Issue, I.id as Issueid, C.cfname, C.configname, C.issuetype, C.project, C.id as ContextID
from jiraissue I
join project P on P.id = I.project 
join contexts C on I.project = C.project and C.issuetype is null
left join fullContext FC on FC.Issue = concat(concat(P.pkey,'-'),I.issuenum)
where FC.Issue is null
),
globalContext as (
select concat(concat(P.pkey,'-'),I.issuenum) as Issue, I.id as Issueid, C.cfname, C.configname, C.issuetype, C.project, C.id as ContextID
from jiraissue I
join project P on P.id = I.project 
join contexts C on C.project is null and C.issuetype is null
left join fullContext FC on FC.Issue = concat(concat(P.pkey,'-'),I.issuenum)
left join typeContext TC on TC.Issue = concat(concat(P.pkey,'-'),I.issuenum)
left join projectContext PC on PC.Issue = concat(concat(P.pkey,'-'),I.issuenum)
where FC.Issue is null
and TC.Issue is null
and PC.Issue is null
),
issueContexts as (
select * 
from fullContext
union
select * 
from typeContext
union
select * 
from projectContext
union
select * 
from globalContext
)
select IC.issue,IC.cfname,IC.configname as IssueContext,CFOP.customvalue as ParentValue, CFOC.customvalue as ChildValue, FCS.configname as ValueContext
from issueContexts IC 
join customfieldvalue CFV on CFV.issue = IC.Issueid
join customfield CF on CF.id = CFV.customfield and CF.cfname = IC.cfname
join customfieldoption CFOC on cast(CFOC.id as varchar) = CFV.stringvalue and CFOC.parentoptionid is not null 
join customfieldoption CFOP on CFOP.id = CFOC.parentoptionid 
join fieldconfigscheme FCS on FCS.id = CFOC.customfieldconfig 
where IC.contextid != CFOC.customfieldconfig 
order by 1

If you need to run this in Oracle, you should only need to change the casting "cast(CFOC.id as varchar)" to "to_char(CFOC.id)"

最終更新日 2021 年 8 月 19 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.