-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b91917
commit 5195646
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
db/migrate/20240207191223_remove_entitlement_mode_host_statuses.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |