Sha256: f5f0c8217c9047b6ae90c006571615e021979297c1689f0f7c2e9355808e8677

Contents?: true

Size: 810 Bytes

Versions: 11

Compression:

Stored size: 810 Bytes

Contents

class ChangeTemplatekindToBootdisk < ActiveRecord::Migration
  def self.up
    kind = TemplateKind.find_or_create_by_name('Bootdisk')

    tmpl_h = Setting.find_by_name('bootdisk_host_template').try(:value)
    tmpl_g = Setting.find_by_name('bootdisk_generic_host_template').try(:value)

    (ConfigTemplate.unscoped.where('name LIKE ?', '%Boot disk%') |
      ConfigTemplate.unscoped.where(:name => [tmpl_h, tmpl_g].compact)).each do |tmpl|
      tmpl.update_attribute(:template_kind_id, kind.id)
    end
  end

  def self.down
    old_kind = TemplateKind.find_by_name('Bootdisk')
    new_kind = TemplateKind.find_by_name('iPXE')
    if old_kind.present? && new_kind.present?
      ConfigTemplate.unscoped.where(:template_kind_id => old_kind.id).update_all(:template_kind_id => new_kind.id)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
foreman_bootdisk-5.0.0 db/migrate/20140522185700_change_templatekind_to_bootdisk.rb
foreman_bootdisk-4.0.2 db/migrate/20140522185700_change_templatekind_to_bootdisk.rb
foreman_bootdisk-4.0.1 db/migrate/20140522185700_change_templatekind_to_bootdisk.rb
foreman_bootdisk-3.2.1 db/migrate/20140522185700_change_templatekind_to_bootdisk.rb
foreman_bootdisk-4.0.0 db/migrate/20140522185700_change_templatekind_to_bootdisk.rb
foreman_bootdisk-3.2.0 db/migrate/20140522185700_change_templatekind_to_bootdisk.rb
foreman_bootdisk-3.1.2 db/migrate/20140522185700_change_templatekind_to_bootdisk.rb
foreman_bootdisk-3.1.1 db/migrate/20140522185700_change_templatekind_to_bootdisk.rb
foreman_bootdisk-3.1.0 db/migrate/20140522185700_change_templatekind_to_bootdisk.rb
foreman_bootdisk-3.0.0 db/migrate/20140522185700_change_templatekind_to_bootdisk.rb
foreman_bootdisk-2.0.8 db/migrate/20140522185700_change_templatekind_to_bootdisk.rb