20170317193015_add_search_index_to_accounts.rb 451 B

1234567891011
  1. # frozen_string_literal: true
  2. class AddSearchIndexToAccounts < ActiveRecord::Migration[5.0]
  3. def up
  4. execute 'CREATE INDEX search_index ON accounts USING gin((setweight(to_tsvector(\'simple\', accounts.display_name), \'A\') || setweight(to_tsvector(\'simple\', accounts.username), \'B\') || setweight(to_tsvector(\'simple\', coalesce(accounts.domain, \'\')), \'C\')));'
  5. end
  6. def down
  7. remove_index :accounts, name: :search_index
  8. end
  9. end