Sha256: 96b6f21db2fceac6cc079ace47ddb7ec885460b4ad7d8e9ed52a36d458295247

Contents?: true

Size: 300 Bytes

Versions: 10

Compression:

Stored size: 300 Bytes

Contents

class RemoveOrphanedAssetPolicies < ActiveRecord::Migration[6.0]
  def up
    orphaned_asset_policy_ids = ForemanOpenscap::AssetPolicy.left_outer_joins(:asset).where(asset: { id: nil }).pluck(:asset_id)
    ForemanOpenscap::AssetPolicy.where(asset_id: orphaned_asset_policy_ids).delete_all
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
foreman_openscap-10.1.0 db/migrate/20240426143215_remove_orphaned_asset_policies.rb
foreman_openscap-10.0.3 db/migrate/20240426143215_remove_orphaned_asset_policies.rb
foreman_openscap-10.0.2 db/migrate/20240426143215_remove_orphaned_asset_policies.rb
foreman_openscap-10.0.1 db/migrate/20240426143215_remove_orphaned_asset_policies.rb
foreman_openscap-10.0.0 db/migrate/20240426143215_remove_orphaned_asset_policies.rb
foreman_openscap-9.0.4 db/migrate/20240426143215_remove_orphaned_asset_policies.rb
foreman_openscap-9.0.3 db/migrate/20240426143215_remove_orphaned_asset_policies.rb
foreman_openscap-9.0.2 db/migrate/20240426143215_remove_orphaned_asset_policies.rb
foreman_openscap-9.0.1 db/migrate/20240426143215_remove_orphaned_asset_policies.rb
foreman_openscap-9.0.0 db/migrate/20240426143215_remove_orphaned_asset_policies.rb