A platform for community discussion. Free, open, simple.
PERF: Add index on email_tokens.token_hash
Dan Ungureanu9a6ec1d0c61b
diff --git a/app/models/email_token.rb b/app/models/email_token.rbindex 020a0112841..2d3dee9b005 100644--- a/app/models/email_token.rb+++ b/app/models/email_token.rb@@ -121,6 +121,7 @@ end## Indexes#-# index_email_tokens_on_token (token) UNIQUE-# index_email_tokens_on_user_id (user_id)+# index_email_tokens_on_token (token) UNIQUE+# index_email_tokens_on_token_hash (token_hash) UNIQUE+# index_email_tokens_on_user_id (user_id)#diff --git a/db/migrate/20211206160211_create_index_on_email_tokens_token_hash.rb b/db/migrate/20211206160211_create_index_on_email_tokens_token_hash.rbnew file mode 100644index 00000000000..1fdffdddb11--- /dev/null+++ b/db/migrate/20211206160211_create_index_on_email_tokens_token_hash.rb@@ -0,0 +1,7 @@+# frozen_string_literal: true++class CreateIndexOnEmailTokensTokenHash < ActiveRecord::Migration[6.1]+ def change+ add_index :email_tokens, :token_hash, unique: true+ end+end