While you shouldn't have to do it often, there are times when you might have duplicate users and you need to merge them together. This usually happens when someone did a CSV import of users (or manually entered them) using a username like
jane.smith, but then later did an LDAP sync where the username in LDAP was
[email protected]. (Most cloud-hosted LDAP providers expect an email address as the username.)
The challenge comes in where you want to keep the existing associations (checkouts, checkins, etc) for
jane.smith but you need to switch over to the LDAP convention so that you don't keep ending up with duplicated users on LDAP sync. This is made even more complicated when you have checkouts/checkins/etc to both
[email protected] and you need to merge those two sets of records into one.
Snipe-IT provides a command-line utility to do this:
What it does
This command allows you to merge the history of users. It looks for users without an email address as their username and merges them into the version that does have an email username. It will then mark the non-email username as deleted. As always, we recommend doing a backup before running any data-altering scripts.
You can view the code in the Github repo here.
Note that this will (currently) ONLY merge non-email usernames into email usernames, NOT the other way around.
Running the command
To run this command, you should be in the main directory of your Snipe-IT installation.
php artisan snipeit:merge-users
Updated over 1 year ago