Skip to content

Commit

Permalink
feat: add index migration (#7050)
Browse files Browse the repository at this point in the history
  • Loading branch information
scmmishra committed May 10, 2023
1 parent 86384bf commit d0a1ad7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/message.rb
Expand Up @@ -26,6 +26,7 @@
# index_messages_on_account_id_and_inbox_id (account_id,inbox_id)
# index_messages_on_additional_attributes_campaign_id (((additional_attributes -> 'campaign_id'::text))) USING gin
# index_messages_on_content (content) USING gin
# index_messages_on_conversation_account_type_created (conversation_id,account_id,message_type,created_at)
# index_messages_on_conversation_id (conversation_id)
# index_messages_on_created_at (created_at)
# index_messages_on_inbox_id (inbox_id)
Expand Down
@@ -0,0 +1,7 @@
class AddIndexToMessagesForReportings < ActiveRecord::Migration[7.0]
disable_ddl_transaction!
def change
add_index :messages, [:conversation_id, :account_id, :message_type, :created_at], name: 'index_messages_on_conversation_account_type_created',
algorithm: :concurrently
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2023_05_09_101256) do
ActiveRecord::Schema[7.0].define(version: 2023_05_10_060828) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "pg_trgm"
Expand Down Expand Up @@ -666,6 +666,7 @@
t.index ["account_id", "inbox_id"], name: "index_messages_on_account_id_and_inbox_id"
t.index ["account_id"], name: "index_messages_on_account_id"
t.index ["content"], name: "index_messages_on_content", opclass: :gin_trgm_ops, using: :gin
t.index ["conversation_id", "account_id", "message_type", "created_at"], name: "index_messages_on_conversation_account_type_created"
t.index ["conversation_id"], name: "index_messages_on_conversation_id"
t.index ["created_at"], name: "index_messages_on_created_at"
t.index ["inbox_id"], name: "index_messages_on_inbox_id"
Expand Down

0 comments on commit d0a1ad7

Please sign in to comment.