Sha256: f242a6aa5bf98b42a673ee1169223e02b22249a065eda78456b9c4254f3a9693

Contents?: true

Size: 390 Bytes

Versions: 5

Compression:

Stored size: 390 Bytes

Contents

class AddManagedToHosts < ActiveRecord::Migration
  def self.up
    add_column :hosts, :managed, :boolean

    Host.reset_column_information

    for host in Host.unscoped.all
      host.update_attribute :managed, !!host.operatingsystem_id and !!host.architecture_id and (!!host.ptable_id or not host.disk.empty?)
    end
  end

  def self.down
    remove_column :hosts, :managed
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/db/migrate/20110301154453_add_managed_to_hosts.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/db/migrate/20110301154453_add_managed_to_hosts.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/db/migrate/20110301154453_add_managed_to_hosts.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/db/migrate/20110301154453_add_managed_to_hosts.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/db/migrate/20110301154453_add_managed_to_hosts.rb