diff --git a/app/models/conversation_with_label.rb b/app/models/conversation_with_label.rb index db3dcda35..2dc225299 100644 --- a/app/models/conversation_with_label.rb +++ b/app/models/conversation_with_label.rb @@ -39,6 +39,7 @@ class ConversationWithLabel < ApplicationRecord def self.refresh # https://github.com/scenic-views/scenic#what-about-materialized-views + # needs atleast one unuque index for concurrent refresh Scenic.database.refresh_materialized_view(table_name, concurrently: true, cascade: false) 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 index 49aa33d28..4d476dd67 100644 --- a/db/migrate/20230602123133_add_index_to_conversation_with_labels_view.rb +++ b/db/migrate/20230602123133_add_index_to_conversation_with_labels_view.rb @@ -2,6 +2,7 @@ class AddIndexToConversationWithLabelsView < ActiveRecord::Migration[7.0] disable_ddl_transaction! def change + # needs atleast one unuque index for concurrent refresh 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