Reset the project counter and reuse Jira issue keys after moving issues
Platform Notice: Data Center and Cloud By Request - This article was written for the Atlassian data center platform but may also be useful for Atlassian Cloud customers. If completing instructions in this article would help you, please contact Atlassian Support and mention it.
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.
*Except Fisheye and Crucible
Summary
After moving issues from project A (for example, moving A-1 and A-2 issues to a new project) the issue keys A-1 and A-2 can't be reused.
Jira retains old issue keys to redirect users
Being unable to reuse issue keys after the issues are moved to a new project is expected behavior. When an issue is moved Jira retains the old issue key as a reference.
This allows the old issue links to work by redirecting visitors to the same issue in the new location project. This also allows Confluence links to the old issue, and static links sent via email or similar to continue to work.
Workaround: Manually reset the project counter in the database
If you wish, you can adjust the SQL database manually to prevent this behavior from occurring, which will also allow you to reuse the issue keys that were moved.
Please note that after executing the steps below, old issue links created before moving the issues will stop redirecting to the new issue location. This is a destructive change and could create confusion for users who have pre-existing links to the moved issues.
Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
Modifying data directly in Jira's database is out of scope for Atlassian Support. These instructions are to help provide guidance if these changes are absolutely needed.
To reset the project count you need to execute the following two steps (please substitute A in the below queries for your project key):
Reset the pcounter field from project table
UPDATE project SET pcounter=0 WHERE pkey='A';
Remove the rows referencing the old issue keys from moved_issue_key
DELETE FROM moved_issue_key WHERE old_issue_key like 'A-%';
After the above steps you should be capable to create issues starting from the number that was set in the pcounter field.