Add unique index to `users.username`

Open Beginner friendly
#13,762 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
postgresql, rust
Domain
databases

Research direction

Start by reading migrations/20150319224700_dumped_migration_93/up.sql for canon_crate_name and migrations/20150319224701_dumped_migration_94/up.sql for the existing crate-name index. Verify that users.username is currently unique before deployment, then add a migration with the normalized unique username index; done means the migration applies successfully and the uniqueness check passes.

Written by the indexing model from the issue text.

Description

We have a postgres function canon_crate_name that replaces hyphens with underscores and lowercases strings. This function is used for the unique crate name index and should be used for the unique username index as well.

I'm open to arguments about whether we should rename canon_crate_name to be something more general such as canon_name or normalized_identifier or similar, or whether we should keep the function name canon_crate_name even as we use it for usernames too.

The PR for this issue should include a migration that adds a unique username index as detailed above.

The admin that deploys this should verify that users.username is actually unique before deploying.

Dominant language
Rust
Stars
3.7k
Forks
751
Avg merge
16h 6m
Merged PRs (30d)
225

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/crates.io

All issues in rust-lang/crates.io

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.