FIX: ensure CategoryUser consistency

This commit is contained in:
Régis Hanol 2015-09-02 22:02:31 +02:00
parent bbe139a7d4
commit 2b9b29c8c8
2 changed files with 5 additions and 0 deletions

View file

@ -13,6 +13,7 @@ module Jobs
UserStat.update_view_counts(13.hours.ago)
Topic.ensure_consistency!
Badge.ensure_consistency!
CategoryUser.ensure_consistency!
end
end
end

View file

@ -92,6 +92,10 @@ class CategoryUser < ActiveRecord::Base
)
end
def self.ensure_consistency!
exec_sql("DELETE FROM category_users WHERE user_id NOT IN (SELECT id FROM users)")
end
private_class_method :apply_default_to_topic, :remove_default_from_topic
end