diff --git a/db/migrate/20230602120613_create_conversation_with_labels.rb b/db/migrate/20230602120613_create_conversation_with_labels.rb index 03084caee..09396afce 100644 --- a/db/migrate/20230602120613_create_conversation_with_labels.rb +++ b/db/migrate/20230602120613_create_conversation_with_labels.rb @@ -1,12 +1,5 @@ class CreateConversationWithLabels < ActiveRecord::Migration[7.0] def change create_view :conversation_with_labels, materialized: true - - add_index :conversation_with_labels, :id, unique: true - add_index :conversation_with_labels, :account_id - add_index :conversation_with_labels, :status - add_index :conversation_with_labels, :custom_attributes, using: :gin - add_index :conversation_with_labels, :labels_array, using: :gin - add_index :conversation_with_labels, :last_activity_at, order: { last_activity_at: :desc } end end diff --git a/db/migrate/20230602123133_add_index_to_conversation_with_labels_view.rb b/db/migrate/20230602123133_add_index_to_conversation_with_labels_view.rb new file mode 100644 index 000000000..49aa33d28 --- /dev/null +++ b/db/migrate/20230602123133_add_index_to_conversation_with_labels_view.rb @@ -0,0 +1,12 @@ +class AddIndexToConversationWithLabelsView < ActiveRecord::Migration[7.0] + disable_ddl_transaction! + + def change + add_index :conversation_with_labels, :id, unique: true, algorithm: :concurrently + add_index :conversation_with_labels, :account_id, algorithm: :concurrently + add_index :conversation_with_labels, :status, algorithm: :concurrently + add_index :conversation_with_labels, :custom_attributes, using: :gin, algorithm: :concurrently + add_index :conversation_with_labels, :labels_array, using: :gin, algorithm: :concurrently + add_index :conversation_with_labels, :last_activity_at, order: { last_activity_at: :desc }, algorithm: :concurrently + end +end diff --git a/db/schema.rb b/db/schema.rb index a1213e6bd..21d6e7fa7 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[7.0].define(version: 2023_06_02_120613) do +ActiveRecord::Schema[7.0].define(version: 2023_06_02_123133) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "pg_trgm"