Sha256: 9c07e05b3aef4be67932146b216000fcf93eaa5079e542216206e679926076d4

Contents?: true

Size: 485 Bytes

Versions: 3

Compression:

Stored size: 485 Bytes

Contents

class RemoveDuplicateBootdiskTemplates < ActiveRecord::Migration
  def up
    template_names = ['Boot disk iPXE - host', 'Boot disk iPXE - generic host']
    template_names.each do |template_name|
      duplicate_template_ids = ProvisioningTemplate.unscoped.where(:name => template_name, :locked => true).order(:created_at => :asc).pluck(:id).drop(1)
      ProvisioningTemplate.unscoped.where(:id => duplicate_template_ids).destroy_all if duplicate_template_ids.any?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_bootdisk-10.0.2 db/migrate/20171009225200_remove_duplicate_bootdisk_templates.rb
foreman_bootdisk-10.0.1 db/migrate/20171009225200_remove_duplicate_bootdisk_templates.rb
foreman_bootdisk-10.0.0 db/migrate/20171009225200_remove_duplicate_bootdisk_templates.rb