From 636eddb1a9fe19b1dda1fb9a9ff624df7410601a Mon Sep 17 00:00:00 2001 From: Molly Struve Date: Thu, 3 Sep 2020 12:18:07 -0500 Subject: [PATCH] [deploy] Optimization:Add Index for User ID and Mailer to Ahoy Messages (#10175) --- ...0902204028_add_user_id_mailer_index_to_ahoy_messages.rb | 7 +++++++ db/schema.rb | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20200902204028_add_user_id_mailer_index_to_ahoy_messages.rb diff --git a/db/migrate/20200902204028_add_user_id_mailer_index_to_ahoy_messages.rb b/db/migrate/20200902204028_add_user_id_mailer_index_to_ahoy_messages.rb new file mode 100644 index 000000000..329624e62 --- /dev/null +++ b/db/migrate/20200902204028_add_user_id_mailer_index_to_ahoy_messages.rb @@ -0,0 +1,7 @@ +class AddUserIdMailerIndexToAhoyMessages < ActiveRecord::Migration[6.0] + disable_ddl_transaction! + + def change + add_index :ahoy_messages, %i[user_id mailer], algorithm: :concurrently + end +end diff --git a/db/schema.rb b/db/schema.rb index 44e2304ec..b1e4ceadb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_09_01_084210) do +ActiveRecord::Schema.define(version: 2020_09_02_204028) do # These are extensions that must be enabled in order to support this database enable_extension "citext" @@ -48,6 +48,7 @@ ActiveRecord::Schema.define(version: 2020_09_01_084210) do t.string "utm_term" t.index ["to"], name: "index_ahoy_messages_on_to" t.index ["token"], name: "index_ahoy_messages_on_token" + t.index ["user_id", "mailer"], name: "index_ahoy_messages_on_user_id_and_mailer" t.index ["user_id", "user_type"], name: "index_ahoy_messages_on_user_id_and_user_type" end