Merge pull request #1556 from eriko/patch-1

Update 20131017014509_add_post_count_to_categories.rb
This commit is contained in:
Robin Ward 2013-10-21 09:42:16 -07:00
commit 4bf064c3c6
1 changed files with 1 additions and 1 deletions

View File

@ -3,7 +3,7 @@ class AddPostCountToCategories < ActiveRecord::Migration
add_column :categories, :post_count, :integer, null: false, default: 0 add_column :categories, :post_count, :integer, null: false, default: 0
execute <<SQL execute <<SQL
UPDATE categories UPDATE categories
SET post_count = (SELECT SUM(posts_count) FROM topics SET post_count = (SELECT COALESCE(SUM(posts_count),0) FROM topics
WHERE category_id = categories.id AND deleted_at IS NULL) WHERE category_id = categories.id AND deleted_at IS NULL)
SQL SQL
end end