If you are upgrading to Unomaly 3.3, you may encounter the following error as you are upgrading:
ERROR: could not create unique index "unlogauth_users_email_key"
DETAIL: Key (email)=(email@example.com) is duplicated.
This migration fails because of an issue where it was possible to have multiple users with the same email address. To fix this, the email address needs to be changed for that user, or the user deleted.
First connect to the database:
Then find the id for the user by running this query, replacing the email address with the one that failed during the upgrade:
select user_id, username, email from unlogauth_users where email = 'firstname.lastname@example.org';
You will get a list of users matching this id:
user_id | username | email
2 | first.last | email@example.com
3 | first | firstname.lastname@example.org
To remove the user with user_id 3, run the following query:
delete from unlogauth_users where user_id = 3;
To instead update the email address for the user, run the following query:
update unlogauth_users set email = 'email@example.com' where user_id = 3;
Afterwards, exit the database shell by pressing control-d, and remove the upgrade lock:
sudo rm /DATA/unomaly_UPGRADING
Finally, re-run the upgrade as normal.