Sha256: fec38cb0903fb37d1264fc6d3c9119345c8f85b41b2aa4ccc7fb5b5c8e91b1c2

Contents?: true

Size: 752 Bytes

Versions: 15

Compression:

Stored size: 752 Bytes

Contents

class UpdateSystemPurposeStatus < ActiveRecord::Migration[6.0]
  def change
    purpose_types = [
      "Katello::PurposeStatus",
      "Katello::PurposeAddonsStatus",
      "Katello::PurposeRoleStatus",
      "Katello::PurposeSlaStatus",
      "Katello::PurposeUsageStatus"
    ]

    # load both sets of host statuses and *then* update them to make sure we update the correct statuses
    unknown_statuses = ::HostStatus::Status.where(type: purpose_types, status: 2).pluck(:id)
    matched_statuses = ::HostStatus::Status.where(type: purpose_types, status: 0).pluck(:id)

    ::HostStatus::Status.where(id: unknown_statuses).update_all(status: 0) # 2 => 0
    ::HostStatus::Status.where(id: matched_statuses).update_all(status: 2) # 0 => 2
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
katello-4.14.2 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.14.1 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.14.0 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.14.0.rc3 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.14.0.rc2 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.14.0.rc1.1 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.14.0.rc1 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.13.1 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.13.0 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.12.1 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.13.0.rc1 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.12.0 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.12.0.rc3 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.12.0.rc2 db/migrate/20200818192230_update_system_purpose_status.rb
katello-4.12.0.rc1 db/migrate/20200818192230_update_system_purpose_status.rb