FIX: correct old username index

(in some cases search was not finding accounts)
This commit is contained in:
Sam 2014-11-18 14:32:13 +11:00
parent f73aa444ee
commit b4844d4477
2 changed files with 12 additions and 1 deletions

View file

@ -66,7 +66,7 @@ class SearchObserver < ActiveRecord::Observer
end end
end end
if obj.class == User && (obj.username_changed? || obj.name_changed?) if obj.class == User && (obj.username_changed? || obj.name_changed?)
SearchObserver.update_users_index(obj.id, obj.username, obj.name) SearchObserver.update_users_index(obj.id, obj.username_lower, obj.name.downcase)
end end
if obj.class == Topic && obj.title_changed? if obj.class == Topic && obj.title_changed?

View file

@ -0,0 +1,11 @@
class CorrectUsernameSearch < ActiveRecord::Migration
def up
execute "update user_search_data
set search_data = TO_TSVECTOR('simple', username_lower || ' ' || lower(name))
from users
where users.id = user_search_data.user_id"
end
def down
end
end