Sha256: 7710d4520ac52abfe29904f08e91630eee8d6550dabe4b7d47bdb10c1c9fa3e0

Contents?: true

Size: 534 Bytes

Versions: 185

Compression:

Stored size: 534 Bytes

Contents

class AddForeignKeyToHypervisorId < ActiveRecord::Migration[5.1]
  def up
    # Update all pools that have a hypervisor reference that's not a host before we add the FK
    ::Katello::Pool.where.not(hypervisor_id: nil).where.not(hypervisor_id: Host::Managed.all).update_all(hypervisor_id: nil)

    add_foreign_key(:katello_pools, :hosts,
                    :name => 'katello_pools_hypervisor_fk', :column => 'hypervisor_id')
  end

  def down
    remove_foreign_key(:katello_pools, :name => 'katello_pools_hypervisor_fk')
  end
end

Version data entries

185 entries across 185 versions & 1 rubygems

Version Path
katello-3.8.1 db/migrate/20180612163403_add_foreign_key_to_hypervisor_id.rb
katello-3.9.0.rc2 db/migrate/20180612163403_add_foreign_key_to_hypervisor_id.rb
katello-3.9.0.rc1 db/migrate/20180612163403_add_foreign_key_to_hypervisor_id.rb
katello-3.7.1.1 db/migrate/20180612163403_add_foreign_key_to_hypervisor_id.rb
katello-3.7.1 db/migrate/20180612163403_add_foreign_key_to_hypervisor_id.rb