How to fix duplicate issue keys in Jira
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Fisheye および Crucible は除く
要約
There are two or more issues with the same key, which isn't expected by Jira and leads to a multitude of errors when searching issues, loading Dashboards or Roadmap Plans.
環境
Jira Core 7.x と 8.x のすべてのバージョン
ソリューション
Please make sure to back up your database before performing any changes.
The query below should list all duplicate issues and their respective internal IDs:
select p.id as "Project ID", p.pkey as "Project Key", a.issuenum as "Issue Num", a.id as "Issue A ID", b.id as "Issue B ID"
from jiraissue a
join jiraissue b on a.issuenum = b.issuenum and a.project = b.project and a.id < b.id
join project p on a.project = p.id
where a.id is not null;
Stop Jira (all Datacenter nodes) and perform the following update for each of the entries above, replacing <Project ID>
and <Issue B ID>
accordingly:
update jiraissue set issuenum = (select (max(issuenum) + 1) from jiraissue where project = <Project ID>) where id = <Issue B ID>;
Start Jira and perform a full lock & reindex in one of the nodes. If running Jira Server, you may start a background reindex.