diff --git a/db/migrate/20200818192230_update_system_purpose_status.rb b/db/migrate/20200818192230_update_system_purpose_status.rb index 76cc7a050c6..8f6156fcf5c 100644 --- a/db/migrate/20200818192230_update_system_purpose_status.rb +++ b/db/migrate/20200818192230_update_system_purpose_status.rb @@ -1,12 +1,18 @@ class UpdateSystemPurposeStatus < ActiveRecord::Migration[6.0] def change - purpose_types = Katello::HostStatusManager::PURPOSE_STATUS.map(&:to_s) + 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: Katello::PurposeStatus::UNKNOWN) # 2 => 0 - ::HostStatus::Status.where(id: matched_statuses).update_all(status: Katello::PurposeStatus::MATCHED) # 0 => 2 + + ::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