Fix order:comm and comment deletion for unbumped comments

fixes #1351, fixes #1352
This commit is contained in:
Toks
2013-12-24 20:59:19 -05:00
parent cac73439bd
commit 8055a7c64b
4 changed files with 58 additions and 12 deletions

View File

@@ -0,0 +1,27 @@
class AddLastCommentBumpedAtToPosts < ActiveRecord::Migration
def self.up
execute "SET statement_timeout = 0"
rename_column :posts, :last_commented_at, :last_comment_bumped_at
rename_index :posts, "index_posts_on_last_commented_at", "index_posts_on_last_comment_bumped_at"
add_column :posts, :last_commented_at, :datetime
Post.joins(:comments).uniq.find_each do |post|
post.update_column(:last_commented_at, post.comments.last.created_at)
end
add_column :comments, :do_not_bump_post, :boolean, :null => false, :default => false
end
def self.down
execute "SET statement_timeout = 0"
remove_column :posts, :last_commented_at
rename_column :posts, :last_comment_bumped_at, :last_commented_at
rename_index :posts, "index_posts_on_last_comment_bumped_at", "index_posts_on_last_commented_at"
remove_column :comments, :do_not_bump_posts
end
end