Sha256: 7507c6d47f10481cf088e7ebaed2eb12313273c7dffb0030e046b2923842d0c3
Contents?: true
Size: 508 Bytes
Versions: 69
Compression:
Stored size: 508 Bytes
Contents
class RemoveArfReportsWithoutPolicy < ActiveRecord::Migration[4.2] def up if User.unscoped.find_by(:login => User::ANONYMOUS_ADMIN) User.as_anonymous_admin do delete_reports end else delete_reports end end def delete_reports ids_to_keep = ForemanOpenscap::ArfReport.unscoped.all.joins(:policy_arf_report).pluck(:id) ForemanOpenscap::ArfReport.unscoped.where.not(:id => ids_to_keep).find_in_batches do |batch| batch.map(&:destroy!) end end end
Version data entries
69 entries across 69 versions & 1 rubygems