Commit 9360f04abeea6ab10ef60093188bf52ff7c350f3
Committed by
Rodrigo Souto
1 parent
6e1949cf
Exists in
master
and in
18 other branches
Add migration to change default private profile content
Signed-off-by: Alvaro Fernando <alvarofernandoms@gmail.com> Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com> Signed-off-by: Eduardo Vital <vitaldu@gmail.com> Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com> Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
Showing
2 changed files
with
21 additions
and
1 deletions
Show diff stats
db/migrate/20150319114233_change_default_content_privacy.rb
0 → 100644
@@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
1 | +class ChangeDefaultContentPrivacy < ActiveRecord::Migration | ||
2 | + def up | ||
3 | + ids = execute("SELECT id from profiles WHERE NOT public_profile") | ||
4 | + profiles_ids = ids.map { |p| p["id"] } | ||
5 | + unless ids.num_tuples.zero? | ||
6 | + execute("UPDATE articles SET published = (1>2), show_to_followers = (1=1) | ||
7 | + WHERE profile_id IN (#{profiles_ids.join(",")}) AND published") | ||
8 | + blocks = Block.includes(:box).where(:boxes => {:owner_type => "Profile", :owner_id => profiles_ids}).where('type != ?', "MainBlock") | ||
9 | + blocks.each do |block| | ||
10 | + block.display_user = 'followers' | ||
11 | + block.save | ||
12 | + end | ||
13 | + end | ||
14 | + change_column :articles, :show_to_followers, :boolean, :default => true | ||
15 | + end | ||
16 | + | ||
17 | + def down | ||
18 | + say "this migration can't be reverted" | ||
19 | + end | ||
20 | +end |
db/schema.rb
@@ -150,7 +150,7 @@ ActiveRecord::Schema.define(:version => 20150408231524) do | @@ -150,7 +150,7 @@ ActiveRecord::Schema.define(:version => 20150408231524) do | ||
150 | t.integer "spam_comments_count", :default => 0 | 150 | t.integer "spam_comments_count", :default => 0 |
151 | t.integer "author_id" | 151 | t.integer "author_id" |
152 | t.integer "created_by_id" | 152 | t.integer "created_by_id" |
153 | - t.boolean "show_to_followers", :default => false | 153 | + t.boolean "show_to_followers", :default => true |
154 | end | 154 | end |
155 | 155 | ||
156 | add_index "articles", ["comments_count"], :name => "index_articles_on_comments_count" | 156 | add_index "articles", ["comments_count"], :name => "index_articles_on_comments_count" |