Skip to content

Commit

Permalink
Refs #37148 - Add migration
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz committed Feb 7, 2024
1 parent 5b91917 commit 5195646
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions db/migrate/20240207191223_remove_entitlement_mode_host_statuses.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class RemoveEntitlementModeHostStatuses < ActiveRecord::Migration[6.1]
def up
obsolete_statuses = [
"Katello::SubscriptionStatus",
"Katello::PurposeStatus",
"Katello::PurposeAddonsStatus",
"Katello::PurposeRoleStatus",
"Katello::PurposeSlaStatus",
"Katello::PurposeUsageStatus"
]

::HostStatus::Status.where(type: obsolete_statuses).delete_all

::TablePreference.where(name: "hosts").each do |table_preference|
next unless table_preference.columns.include?("subscription_status")
new_columns = table_preference.columns - ["subscription_status"]
if new_columns.present?
table_preference.columns = new_columns
table_preference.save(validate: false)
else
table_preference.destroy
end
end
end
end

0 comments on commit 5195646

Please sign in to comment.