chore: Add index on conversations.uuid (#5179)

- We search for conversations by this attribute (e.g. in ReplyMailbox and CsatSurveyController) so it seems like we should have an index on it.
This commit is contained in:
Jordan Brough 2022-08-23 07:35:30 -06:00 committed by GitHub
parent 5957edc76b
commit 9ddf4c205c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

View file

@ -36,6 +36,7 @@
# 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)
# index_conversations_on_uuid (uuid) UNIQUE
#
class Conversation < ApplicationRecord
@ -51,6 +52,7 @@ class Conversation < ApplicationRecord
before_validation :validate_additional_attributes
validates :additional_attributes, jsonb_attributes_length: true
validates :custom_attributes, jsonb_attributes_length: true
validates :uuid, uniqueness: true
validate :validate_referer_url
enum status: { open: 0, resolved: 1, pending: 2, snoozed: 3 }

View file

@ -0,0 +1,5 @@
class AddConversationUuidUniqueIndex < ActiveRecord::Migration[6.1]
def change
add_index :conversations, :uuid, unique: true
end
end

View file

@ -413,6 +413,7 @@ ActiveRecord::Schema.define(version: 2022_08_09_104508) do
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"
t.index ["uuid"], name: "index_conversations_on_uuid", unique: true
end
create_table "csat_survey_responses", force: :cascade do |t|