Sha256: 41a1f35041a3c1c99608b323bc7ca108cf1a6fc1c93449557baea33547a2a82b
Contents?: true
Size: 1.01 KB
Versions: 19
Compression:
Stored size: 1.01 KB
Contents
class AddHostContentViewEnvironment < ActiveRecord::Migration def up add_column :hosts, :content_view_id, :integer, :null => true add_column :hosts, :lifecycle_environment_id, :integer, :null => true add_column :hostgroups, :content_view_id, :integer, :null => true add_column :hostgroups, :lifecycle_environment_id, :integer, :null => true [Hostgroup, Host::Managed].each do |model| model.find_each do |host| lifecycle_environment = host.environment.try(:lifecycle_environment) content_view = host.environment.try(:content_view) if lifecycle_environment && content_view host.update_column(:content_view_id, content_view.id) host.update_column(:lifecycle_environment_id, lifecycle_environment.id) end end end end def down remove_column :hosts, :content_view_id remove_column :hosts, :lifecycle_environment_id remove_column :hostgroups, :content_view_id remove_column :hostgroups, :lifecycle_environment_id end end
Version data entries
19 entries across 19 versions & 1 rubygems