How to migrate user contributions to new user name
Versions of JIRA prior to version 6 lacked the Rename User functionality available to admins today. In order to make a username change, a new user account needed to be created and data from the deprecated user account needed to be migrated to that new account using a hack on an XML backup of the system. This guide will walk any admins still running an older version of JIRA through this hack. Please note that Atlassian recommends that admins consider upgrading to the latest version of JIRA applications to take advantage of the Rename Users functionality rather than rely on this hack.
The content on this page relates to platforms that are not supported by JIRA applications. Consequently, Atlassian can not guarantee providing any support for it. Please be aware that this material is provided for your information only and using it is done at your own risk.
Steps to Migrate the User Contributions
The example given below is the method to migrate the contributions for username 'david.m' to 'david.martin' with the assumption user is created from an LDAP integration.
- First, create an XML backup from your JIRA instance. (Do not create the user david.martin just yet)
- Shut down JIRA.
Use the following command to find all the strings that contain the username david.m
egrep -n david.m entities.xml
Change all the affected strings from 'david.m' to 'david.martin'. The example command below applies to linux and unix platforms:
cat entities.xml | sed 's/david.m/david.martin/g' > entities-patched.xml
Note: This does not apply if the username is mixed case, so if you have a mixed case username situation, please perform the replacement twice. (Example: once for david.m, once for David.M)
Verify all the entities changed correctly:
grep david.m entities-patched.xml
This should not return result if fully replaced.
Optional, check which string is replaced by comparing:
diff -y --suppress-common-lines entities.xml entities-patched.xml
Finally replace the entities.xml with the newly created entities file:
mv -f entities-patched.xml entities.xml
- Create the user david.martin on your LDAP server.
- Perform a restore to your test server to make sure that the contributions are successfully transferred. (DO NOT restore to the production server without testing it). Run a full synchronization on your user directories if the username is greyed out.
You might run into the following problem if you have the user created before migration:
Error importing data: java.lang.Exception: com.atlassian.jira.exception.DataAccessException: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:UserHistoryItem][id,28185][username,david.martin][entityId,10000][lastViewed,1315819985752][type,Dashboard] (SQL Exception while executing the following:INSERT INTO public.userhistoryitem (ID, entitytype, entityid, USERNAME, lastviewed, data) VALUES (?, ?, ?, ?, ?, ?) (ERROR: duplicate key value violates unique constraint "uh_type_user_entity"))
This is due to multiple entries for the user david.martin being detected and therefore cannot be inserted into the table.
grep UserHistoryItem entities.xml | grep david.martin | grep 10000
Try to locate the duplicated entries with the command above. Note: the 10000 value is referring to the entityId found on the error message. It might be different on different instances.