How to reactivate a deleted user from the database?

If you have removed a QMetry user by deactivating and then accidentally deleting their account, and subsequently tried to create a new account using the same username, or email address, the admin may encounter an error message saying “Oh Snap! Duplicate username is not allowed.” and the user may encounter the below error upon login to QMetry.

This is because if a user has been deleted from QMetry, their username will continue to exist on the backend; hence, their username cannot be re-used. Deleting a user from QMetry is not recommended because when a user is deleted, it is a soft delete from the UI to preserve the user’s asset assignments/ownership, other details, and histories available in QTM - with deleted users being shown in QMetry suffixed with [X] in their assets to indicate they’re deleted.

Instead, users who are not required should be deactivated. Deactivated users do not count against your license.

Steps to Reactivate a Deleted User (from the backend):

To reactivate a deleted user, follow the steps below:

  1. Go inside the QMetry database docker container - docker exec -it qmetryapp_db bash

  2. Login to MySQL DB - mysql -u{username} -p{password} (replace the username and password)

    • i.e. mysql -uroot -pqmetry

  3. use qmetry; (switch to the “qmetry” schema)

  4. Execute the below query in sequence:

    • Note: Replace the loginId with the actual username of the deleted user.

    • Query to find/search the deleted user.

      • select * from user where loginId = '<username>';
    • Query to reactivate the user.

      • update user set isPasswordExpired =0 , isDeleted =0 , isActive = 1, initialPasswordChanged = 1, isPasswordReset = 0,lastPasswordUpdatedDate = null where loginId = '<username>' and userId > 0;
  5. exit (to exit from MySQL).

  6. exit (to exit from docker container).

Steps to be followed in QMetry after the user account is reactivated:

  • Go to QMetry > Customization > Users > "Search for the user whose account got reactivated."

  • Click on “Edit”.

  • Remove “[X]” from the “Alias” and “Email” as shown below:

  • Un-assign projects (if any) and reassign the projects/role again.

  • Update.