Sha256: 8e6fee6e748dfc1459c3c312478d0ccd4d36f8ca13134b049914cb42fb1e7dfa

Contents?: true

Size: 566 Bytes

Versions: 1

Compression:

Stored size: 566 Bytes

Contents

class AddContentHostIdToSmartProxy < ActiveRecord::Migration
  class SmartProxy < ActiveRecord::Base
  end

  class Katello::System < ActiveRecord::Base
  end

  def change
    add_column :smart_proxies, :content_host_id, :integer
    add_foreign_key :smart_proxies, :katello_systems, :column => "content_host_id"

    SmartProxy.all.each do |proxy|
      content_host = ::Katello::System.where(:name => proxy.name).order("created_at DESC").first

      if content_host
        proxy.content_host_id = content_host.id
        proxy.save!
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katello-2.2.2 db/migrate/20150423134004_add_content_host_id_to_smart_proxy.rb