I’m putting together an app as an exercise that sends confirmation emails (I should add that I don’t have any real previous app-making experience, I’m learning in Elixir/Phoenix). Seems simple enough, I generate a random value, salt it with user email (a unique field) to make it unique, then store it in the user and mail the user a link. User clicks the confirmation link and I check to make sure it’s in the db (and within a predetermined time limit). If all is good, I delete the token (in case the account is ever deactivated, to prevent reactivation) and mark the user’s confirmed time.
So the question, since this is a learning experience, in a more serious setting, would I want to have an index on the confirmation token column to speed up the search? If so how would this look, unique on email and confirmation_token (since the token can be/will be nil)? Or would the token itself be handled differently?