adding counter_cache to comments children and WIPing on the issue
This commit is contained in:
13
db/migrate/20150811161459_add_children_count_to_comments.rb
Normal file
13
db/migrate/20150811161459_add_children_count_to_comments.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class AddChildrenCountToComments < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :comments, :children_count, :integer, default: 0
|
||||
|
||||
Comment.find_each do |comment|
|
||||
Comment.reset_counters(comment.id, :children)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :comments, :children_count
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user