Make username field unique in users-permissions

Adding this unique index caused problems with Strapi (will no longer start) after making changes to content-types. Not exactly sure why. A better solution for Postgres is to add a constraint instead of a unique index. Works great although the register controller method code no longer catches the ‘Username already taken’ error properly. The service add method within register throws an error somewhere in a middleware with the message ‘This attribute must be unique’.

1 Like