PERF: allow looking up incoming email by user_id

This speeds up the ability to remove users from the system
This commit is contained in:
Sam Saffron 2019-04-26 22:33:01 +10:00
parent 26b4dbde41
commit 378fe1c1cf
2 changed files with 6 additions and 0 deletions

View File

@ -52,4 +52,5 @@ end
# index_incoming_emails_on_error (error)
# index_incoming_emails_on_message_id (message_id)
# index_incoming_emails_on_post_id (post_id)
# index_incoming_emails_on_user_id (user_id) WHERE (user_id IS NOT NULL)
#

View File

@ -0,0 +1,5 @@
class AddIncomingEmailByUserIdIndex < ActiveRecord::Migration[5.2]
def change
add_index :incoming_emails, [:user_id], where: 'user_id IS NOT NULL'
end
end