Adding database index on full-text search for better performance.

This commit is contained in:
Christoph Haas 2013-08-08 22:32:41 +02:00
parent d1d4cea63a
commit 110cd16d6e
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,11 @@
class AddSearchIndexToPackages < ActiveRecord::Migration
def up
execute "create index packages_name on packages using gin(to_tsvector('english', name))"
execute "create index packages_description on packages using gin(to_tsvector('english', description))"
end
def down
execute "drop index packages_name"
execute "drop index packages_description"
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20130727112955) do
ActiveRecord::Schema.define(version: 20130808195123) do
create_table "admins", force: true do |t|
t.string "username", limit: 20