title: index_users_on_unlock_token unique validation error in rails / devise
body: <p>I'm using Rails 4 and devise, and am running into an issue when I try to update users from my admin console (I'm using Rails Admin). Every time I try to update, it gives me an error:</p>
  
  <pre><code>    ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_users_on_unlock_token"
  </code></pre>
  
  <p>This is occurring presumably because the unlock_token field is null for most users. But surely fields that can be null can still be indexed? The unlock_token is only set when a user is locked out of their account right?</p>
  
  <p>I can easily avoid this issue by entering a random string in the confirmation token field, but this seems like a bad way to deal with it. Any better ideas?</p>
  
  <p>My Users table definition (well, the relevant portion of it):</p>
  
  <pre><code>create_table "users", force: true do |t|
      t.string   "email",                                               default: "",    null: false
      t.string   "encrypted_password",                                  default: "",    null: false
      t.string   "screen_name"
      t.string   "reset_password_token"
      t.datetime "reset_password_sent_at"
      t.datetime "remember_created_at"
      t.integer  "sign_in_count",                                       default: 0
      t.datetime "current_sign_in_at"
      t.datetime "last_sign_in_at"
      t.string   "current_sign_in_ip"
      t.string   "last_sign_in_ip"
      t.string   "confirmation_token"
      t.datetime "confirmed_at"
      t.datetime "confirmation_sent_at"
      t.integer  "failed_attempts",                                     default: 0
      t.string   "unlock_token"
      t.datetime "locked_at"
  end
  </code></pre>
  
  <p>The error from my logs:</p>
  
  <pre><code>  SQL (10.5ms)  UPDATE "users" SET "unlock_token" = $1, "updated_at" = $2 WHERE "users"."id" = 7  [["unlock_token", ""], ["updated_at", Mon, 24 Feb 2014 02:59:58 UTC +00:00]]
  PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_users_on_unlock_token"
  DETAIL:  Key (unlock_token)=() already exists.
  </code></pre>