fix: Added pg_trgm extension
This commit is contained in:
parent
4d2afface2
commit
5c322e96a4
4 changed files with 6 additions and 5 deletions
|
@ -4,10 +4,9 @@ module MultiSearchableHelpers
|
|||
included do
|
||||
PgSearch.multisearch_options = {
|
||||
using: {
|
||||
trigram: {},
|
||||
tsearch: {
|
||||
prefix: true,
|
||||
any_word: true,
|
||||
normalization: 3
|
||||
any_word: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +15,7 @@ module MultiSearchableHelpers
|
|||
return if contact_pg_search_record.present?
|
||||
|
||||
initialize_contact_pg_search_record.update!(
|
||||
content: "#{contact.id} #{contact.email} #{contact.name} #{contact.phone_number}",
|
||||
content: "#{contact.id} #{contact.email} #{contact.name} #{contact.phone_number} #{contact.account_id}",
|
||||
conversation_id: id
|
||||
)
|
||||
end
|
||||
|
|
|
@ -154,7 +154,7 @@ class Contact < ApplicationRecord
|
|||
INSERT INTO pg_search_documents (searchable_type, searchable_id, content, account_id, conversation_id, created_at, updated_at)
|
||||
SELECT 'Contact' AS searchable_type,
|
||||
contacts.id AS searchable_id,
|
||||
CONCAT_WS(' ', contacts.email, contacts.name, contacts.phone_number, contacts.id, contacts.account_id) AS content,
|
||||
CONCAT_WS(' ', contacts.id, contacts.email, contacts.name, contacts.phone_number, contacts.account_id) AS content,
|
||||
contacts.account_id::int AS account_id,
|
||||
conversations.id AS conversation_id,
|
||||
now() AS created_at,
|
||||
|
|
|
@ -3,6 +3,7 @@ class EnableMultiSearchable < ActiveRecord::Migration[6.1]
|
|||
Contact.rebuild_pg_search_documents
|
||||
PgSearch::Multisearch.rebuild(Conversation)
|
||||
PgSearch::Multisearch.rebuild(Message)
|
||||
execute 'create extension pg_trgm;'
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
|
@ -14,6 +14,7 @@ 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"
|
||||
enable_extension "pg_trgm"
|
||||
enable_extension "pgcrypto"
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
|
Loading…
Reference in a new issue