mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Initial release of Discourse
This commit is contained in:
13
db/migrate/20120514144549_add_reply_count_to_posts.rb
Normal file
13
db/migrate/20120514144549_add_reply_count_to_posts.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class AddReplyCountToPosts < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :posts, :reply_count, :integer, null: false, default: 0
|
||||
|
||||
execute "UPDATE posts
|
||||
SET reply_count = (SELECT count(*) FROM posts AS p2 WHERE p2.reply_to_post_number = posts.post_number)"
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :posts, :reply_count
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user