travis-ci/travis-ci — Issue #393: Authorizing with a login name that has previously been authorized raises ActiveRecord::RecordNotUnique
Author: definitelylion
Created: 2012-01-21 02:29:21+00:00
State: open

### Steps to reproduce
0. Authorize Travis with a GitHub account
1. Delete that GitHub account
2. Create a new GitHub account using the same login name as the old account
3. Authorize Travis with the new account

### Result

Travis raises:

ActiveRecord::RecordNotUnique in Users::OmniauthCallbacksController#github

PGError: ERROR: duplicate key value violates unique constraint "index_users_on_login"
: INSERT INTO "users" ("created_at", "email", "github_id", "github_oauth_token", "is_admin", "login", "name", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id"

### Expected

Authorization is successful, and I am greeted greeted with the Travis profile page as per usual.

A GitHub login name cannot be assumed to uniquely identify a single account over time. IMHO, it isn't a good candidate for a unique key constraint (as opposed to e.g. `github_id`).