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