Updating Users with Duplicate user_ids

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:

  1. Create a new database connection (New-DB) that will be used to import the duplicated users.
  2. 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.
  3. Import the users with new user_id into the New-DB database.
  4. Delete the old database and enable to new database for the same applications.
1 Like