From 9a6ec1d0c61b98b763c06ba6ae67809de29f22eb Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Mon, 6 Dec 2021 19:17:32 +0200 Subject: [PATCH] PERF: Add index on email_tokens.token_hash --- app/models/email_token.rb | 5 +++-- ...211206160211_create_index_on_email_tokens_token_hash.rb | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20211206160211_create_index_on_email_tokens_token_hash.rb diff --git a/app/models/email_token.rb b/app/models/email_token.rb index 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.rb new file mode 100644 index 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