class FixSearchIndexInPackages < ActiveRecord::Migration[5.0]
  def up
    execute "drop index packages_name"
    execute "drop index packages_description"
    execute "create index packages_fts on packages using gin((
      to_tsvector('english', coalesce(\"packages\".\"name\"::text, ''))
      ||
      to_tsvector('english', coalesce(\"packages\".\"description\"::text, ''))
      ||
      to_tsvector('english', coalesce(\"packages\".\"long_description\"::text, ''))
    ))"
  end

  def down
    execute "drop index packages_fts"
  end
end
