fix: Add index in conversation and reporting event (#4577)

Fixes chatwoot/product#422
This commit is contained in:
Aswin Dev P.S 2022-04-28 16:58:06 +05:30 committed by GitHub
parent cb38ec3267
commit 8d04894744
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 6 deletions

View file

@ -31,6 +31,7 @@
# index_conversations_on_assignee_id_and_account_id (assignee_id,account_id) # index_conversations_on_assignee_id_and_account_id (assignee_id,account_id)
# index_conversations_on_campaign_id (campaign_id) # index_conversations_on_campaign_id (campaign_id)
# index_conversations_on_contact_inbox_id (contact_inbox_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_status_and_account_id (status,account_id)
# index_conversations_on_team_id (team_id) # index_conversations_on_team_id (team_id)
# #

View file

@ -17,11 +17,12 @@
# #
# Indexes # Indexes
# #
# index_reporting_events_on_account_id (account_id) # index_reporting_events_on_account_id (account_id)
# index_reporting_events_on_created_at (created_at) # index_reporting_events_on_conversation_id (conversation_id)
# index_reporting_events_on_inbox_id (inbox_id) # index_reporting_events_on_created_at (created_at)
# index_reporting_events_on_name (name) # index_reporting_events_on_inbox_id (inbox_id)
# index_reporting_events_on_user_id (user_id) # index_reporting_events_on_name (name)
# index_reporting_events_on_user_id (user_id)
# #
class ReportingEvent < ApplicationRecord class ReportingEvent < ApplicationRecord

View file

@ -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

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements" 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 ["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 ["campaign_id"], name: "index_conversations_on_campaign_id"
t.index ["contact_inbox_id"], name: "index_conversations_on_contact_inbox_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 ["status", "account_id"], name: "index_conversations_on_status_and_account_id"
t.index ["team_id"], name: "index_conversations_on_team_id" t.index ["team_id"], name: "index_conversations_on_team_id"
end end
@ -662,6 +663,7 @@ ActiveRecord::Schema.define(version: 2022_04_24_081117) do
t.datetime "event_start_time" t.datetime "event_start_time"
t.datetime "event_end_time" t.datetime "event_end_time"
t.index ["account_id"], name: "index_reporting_events_on_account_id" 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 ["created_at"], name: "index_reporting_events_on_created_at"
t.index ["inbox_id"], name: "index_reporting_events_on_inbox_id" t.index ["inbox_id"], name: "index_reporting_events_on_inbox_id"
t.index ["name"], name: "index_reporting_events_on_name" t.index ["name"], name: "index_reporting_events_on_name"