diff --git a/db/migrate/20141229173351_fix_search_index_in_packages.rb b/db/migrate/20141229173351_fix_search_index_in_packages.rb new file mode 100644 index 0000000..10bdfb3 --- /dev/null +++ b/db/migrate/20141229173351_fix_search_index_in_packages.rb @@ -0,0 +1,17 @@ +class FixSearchIndexInPackages < ActiveRecord::Migration + 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