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

Version Path
katello-3.0.2 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-2.4.5 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-3.0.1 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-2.4.4 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-3.0.0 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-2.4.3 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-3.0.0.rc7 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-3.0.0.rc5 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-2.4.2 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-3.0.0.rc4 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-3.0.0.rc3 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-3.0.0.rc2 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-3.0.0.rc1 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-2.4.1 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-2.4.0 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-2.4.0.rc3 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-2.4.0.rc2 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-2.4.0.rc1 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-2.2.2 db/migrate/20141222151001_add_host_content_view_environment.rb