From dc0dc7e1bb5b28ecc6f7b616469b489d50cdfacc Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Fri, 5 Feb 2010 19:27:10 -0300 Subject: [PATCH] Adding migrate to add visible=true to profiles --- db/migrate/083_set_visible_to_profiles.rb | 21 +++++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 db/migrate/083_set_visible_to_profiles.rb diff --git a/db/migrate/083_set_visible_to_profiles.rb b/db/migrate/083_set_visible_to_profiles.rb new file mode 100644 index 0000000..938cddf --- /dev/null +++ b/db/migrate/083_set_visible_to_profiles.rb @@ -0,0 +1,21 @@ +class Environment < ActiveRecord::Base + set_table_name 'environments' + serialize :settings, Hash +end + +class SetVisibleToProfiles < ActiveRecord::Migration + def self.up + templates = [] + Environment.all.each do |e| + templates << e.settings[:person_template_id] + templates << e.settings[:enterprise_template_id] + templates << e.settings[:inactive_enterprise_template_id] + templates << e.settings[:community_template_id] + end + execute "update profiles set visible=(1=1) where id NOT IN (#{templates.compact.join(',')})" + end + + def self.down + say("Nothing to undo (cannot recover the data)") + end +end diff --git a/db/schema.rb b/db/schema.rb index c208202..0c33884 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 82) do +ActiveRecord::Schema.define(:version => 83) do create_table "article_versions", :force => true do |t| t.integer "article_id" -- libgit2 0.21.2