Sha256: e137b92c7accb0f6ff503c01addb5a385eacb285af3036364c64f143960d9f12

Contents?: true

Size: 930 Bytes

Versions: 3

Compression:

Stored size: 930 Bytes

Contents

class RemoveEntitlementModeHostStatuses < ActiveRecord::Migration[6.1]
  class FakeTablePreference < ApplicationRecord
    self.table_name = 'table_preferences'
    serialize :columns
  end

  def up
    obsolete_statuses = [
      "Katello::SubscriptionStatus",
      "Katello::PurposeStatus",
      "Katello::PurposeAddonsStatus",
      "Katello::PurposeRoleStatus",
      "Katello::PurposeSlaStatus",
      "Katello::PurposeUsageStatus",
    ]

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

    FakeTablePreference.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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
katello-4.15.0 db/migrate/20240207191223_remove_entitlement_mode_host_statuses.rb
katello-4.15.0.rc2 db/migrate/20240207191223_remove_entitlement_mode_host_statuses.rb
katello-4.15.0.rc1 db/migrate/20240207191223_remove_entitlement_mode_host_statuses.rb