diff --git a/app/models/conversation.rb b/app/models/conversation.rb index cf3a4c256..ac02260a5 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -31,6 +31,7 @@ # index_conversations_on_assignee_id_and_account_id (assignee_id,account_id) # index_conversations_on_campaign_id (campaign_id) # index_conversations_on_contact_inbox_id (contact_inbox_id) +# index_conversations_on_last_activity_at (last_activity_at) # index_conversations_on_status_and_account_id (status,account_id) # index_conversations_on_team_id (team_id) # diff --git a/app/models/reporting_event.rb b/app/models/reporting_event.rb index 02f6e4d20..3568d2a06 100644 --- a/app/models/reporting_event.rb +++ b/app/models/reporting_event.rb @@ -17,11 +17,12 @@ # # Indexes # -# index_reporting_events_on_account_id (account_id) -# index_reporting_events_on_created_at (created_at) -# index_reporting_events_on_inbox_id (inbox_id) -# index_reporting_events_on_name (name) -# index_reporting_events_on_user_id (user_id) +# index_reporting_events_on_account_id (account_id) +# index_reporting_events_on_conversation_id (conversation_id) +# index_reporting_events_on_created_at (created_at) +# index_reporting_events_on_inbox_id (inbox_id) +# index_reporting_events_on_name (name) +# index_reporting_events_on_user_id (user_id) # class ReportingEvent < ApplicationRecord diff --git a/db/migrate/20220428101325_add_index_to_conversation_and_reporting_event.rb b/db/migrate/20220428101325_add_index_to_conversation_and_reporting_event.rb new file mode 100644 index 000000000..f1b982a8b --- /dev/null +++ b/db/migrate/20220428101325_add_index_to_conversation_and_reporting_event.rb @@ -0,0 +1,6 @@ +class AddIndexToConversationAndReportingEvent < ActiveRecord::Migration[6.1] + def change + add_index :conversations, :last_activity_at + add_index :reporting_events, :conversation_id + end +end diff --git a/db/schema.rb b/db/schema.rb index a30f6e6cf..cc619bc18 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: 2022_04_24_081117) do +ActiveRecord::Schema.define(version: 2022_04_28_101325) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" @@ -361,6 +361,7 @@ ActiveRecord::Schema.define(version: 2022_04_24_081117) do t.index ["assignee_id", "account_id"], name: "index_conversations_on_assignee_id_and_account_id" t.index ["campaign_id"], name: "index_conversations_on_campaign_id" t.index ["contact_inbox_id"], name: "index_conversations_on_contact_inbox_id" + t.index ["last_activity_at"], name: "index_conversations_on_last_activity_at" t.index ["status", "account_id"], name: "index_conversations_on_status_and_account_id" t.index ["team_id"], name: "index_conversations_on_team_id" end @@ -662,6 +663,7 @@ ActiveRecord::Schema.define(version: 2022_04_24_081117) do t.datetime "event_start_time" t.datetime "event_end_time" t.index ["account_id"], name: "index_reporting_events_on_account_id" + t.index ["conversation_id"], name: "index_reporting_events_on_conversation_id" t.index ["created_at"], name: "index_reporting_events_on_created_at" t.index ["inbox_id"], name: "index_reporting_events_on_inbox_id" t.index ["name"], name: "index_reporting_events_on_name"