Sha256: 4b24d86f1ed53101312a4b9b3115ba52665a151c05bc752b02559c167dbad5d0

Contents?: true

Size: 1.01 KB

Versions: 119

Compression:

Stored size: 1.01 KB

Contents

class AddHostContentViewEnvironment < ActiveRecord::Migration[4.2]
  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

119 entries across 119 versions & 1 rubygems

Version Path
katello-4.15.0.rc2 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.15.0.rc1 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.14.1 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.14.0 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.14.0.rc3 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.14.0.rc2 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.14.0.rc1.1 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.14.0.rc1 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.13.1 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.13.0 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.12.1 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.13.0.rc1 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.12.0 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.12.0.rc3 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.12.0.rc2 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.12.0.rc1 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.11.1 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.11.0 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.11.0.rc2 db/migrate/20141222151001_add_host_content_view_environment.rb
katello-4.11.0.rc1 db/migrate/20141222151001_add_host_content_view_environment.rb