Sha256: cf61ba8d4fc79255b7dffe700afb5ce304efa2044f8dfe2e08adb1ed75cb5cf2

Contents?: true

Size: 449 Bytes

Versions: 5

Compression:

Stored size: 449 Bytes

Contents

class AddLabelToHostGroup < ActiveRecord::Migration

  def self.up
    add_column :hostgroups, :label, :string

    Hostgroup.reset_column_information
    execute "UPDATE hostgroups set label = name WHERE ancestry IS NULL"
    Hostgroup.where("ancestry IS NOT NULL").each do |hostgroup|
      hostgroup.label = hostgroup.get_label
      hostgroup.save_without_auditing
    end
  end

  def self.down
    remove_column :hostgroups, :label
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

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