This repository has been archived on 2025-05-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
discourse/db/migrate/20120523184307_add_replies_to_forum_threads.rb

8 lines
332 B
Ruby
Raw Normal View History

2013-02-05 14:16:51 -05:00
class AddRepliesToForumThreads < ActiveRecord::Migration
def change
add_column :forum_threads, :reply_count, :integer, default: 0, null: false
execute "UPDATE forum_threads SET reply_count = (SELECT COUNT(*) FROM posts WHERE posts.reply_to_post_number IS NOT NULL AND posts.forum_thread_id = forum_threads.id)"
end
end