Commit 41a24f5c9e97c30fd834ebeb12f1b3f384cf7f88
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'following' into staging
Conflicts: app/models/article.rb app/models/article_follower.rb app/models/person.rb test/unit/article_follower_test.rb
Showing
3 changed files
with
27 additions
and
1 deletions
Show diff stats
app/models/article_follower.rb
db/migrate/20150909091347_add_followers_count_to_article.rb
0 → 100644
... | ... | @@ -0,0 +1,15 @@ |
1 | +class AddFollowersCountToArticle < ActiveRecord::Migration | |
2 | + | |
3 | + def self.up | |
4 | + add_column :articles, :followers_count, :integer, :default => 0 | |
5 | + add_column :article_versions, :followers_count, :integer | |
6 | + | |
7 | + execute "update articles set followers_count = (select count(*) from article_followers where article_followers.article_id = articles.id)" | |
8 | + end | |
9 | + | |
10 | + def self.down | |
11 | + remove_column :article_versions, :followers_count | |
12 | + remove_column :articles, :followers_count | |
13 | + end | |
14 | + | |
15 | +end | ... | ... |