Add a unique constraint for name and user ID on the pseuds table

Description

We are enforcing uniqueness on pseud names per user in Rails but not at the database level. Users who somehow end up with duplicate pseuds will be unable to change their passwords, because their duplicate pseuds are not valid (this symptom is similar to ).

We need:

  • A rake task to rename existing duplicates (e.g. "pseud" to "pseud_2") so they don't prevent the creation of a unique index.

  • A migration to add said unique index. The table has more than 500k rows, so we probably want to use pt-online-schema-change here. There’s an example of how to write such a migration here.

How to test:

  • You need to have duplicate pseuds on staging. Database admins can force them into existence if necessary. Check that you cannot change your password ("Invalid pseud error").

  • (Server admin) Run the rake task and make sure the duplicate pseuds get renamed.

  • (Server admin) Run the migration.

  • Check that you can change your password.

Assignee

Unassigned

Reporter

redsummernight

Roadmap

Pseuds

Priority

Medium

Affects versions

Fix versions

None

Components

BackEnd

Difficulty

Medium

Milestone

Internal 0.9
Configure