fix: migration for rebuilding multi model search

This commit is contained in:
Tejaswini Chile 2022-12-12 11:57:01 +05:30
parent 723968f042
commit f513bdb97d
5 changed files with 19 additions and 2 deletions

View file

@ -13,8 +13,10 @@
# display_name :string
# email :string
# encrypted_password :string default(""), not null
# failed_attempts :integer
# last_sign_in_at :datetime
# last_sign_in_ip :string
# locked_at :datetime
# message_signature :text
# name :string not null
# provider :string default("email"), not null
@ -28,6 +30,7 @@
# ui_settings :jsonb
# uid :string default(""), not null
# unconfirmed_email :string
# unlock_token :string
# created_at :datetime not null
# updated_at :datetime not null
#

View file

@ -13,8 +13,10 @@
# display_name :string
# email :string
# encrypted_password :string default(""), not null
# failed_attempts :integer
# last_sign_in_at :datetime
# last_sign_in_ip :string
# locked_at :datetime
# message_signature :text
# name :string not null
# provider :string default("email"), not null
@ -28,6 +30,7 @@
# ui_settings :jsonb
# uid :string default(""), not null
# unconfirmed_email :string
# unlock_token :string
# created_at :datetime not null
# updated_at :datetime not null
#

View file

@ -0,0 +1,11 @@
class EnableMultiSearchable < ActiveRecord::Migration[6.1]
def up
Contact.rebuild_pg_search_documents
PgSearch::Multisearch.rebuild(Conversation)
PgSearch::Multisearch.rebuild(Message)
end
def down
PgSearch::Document.delete_all
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_12_05_081737) do
ActiveRecord::Schema.define(version: 2022_12_12_061802) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"

View file

@ -44,7 +44,7 @@ describe ::TextSearch do
params = { q: 'pot' }
result = described_class.new(user_1, params).perform
expect(result[:messages].length).to be 1
expect(result[:contacts].length).to be 1
expect(result[:contacts].length).to be 2
end
end
end