Problem statement
If there are multiple custom database connections in a tenant, it is possible to accidentally create multiple users with the same user_id. Since the user_id is the same, attempting to update the user with the /api/v2/users
endpoint only chooses one of the profiles.
Solution
There is no way to selectively patch a user in this scenario, the user_id’s must be unique.
Here is an approach to maintaining the two user profiles while changing the user_id for one of them so they become unique within a tenant:
- Create a new database connection (New-DB) that will be used to import the duplicated users.
- Export users from one of the custom database connections and modify the user_id in the exported JSON to include a prefix of the new connection (e.g. “New-DB|{unique-identifier}”) per documented best practices.
- Import the users with new user_id into the New-DB database.
- Delete the old database and enable to new database for the same applications.