blob: f6b7e1848113eb02b1f25b6ca897db5d5f381bcc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# frozen_string_literal: true
module Gitlab
module BackgroundMigration
# Deletes orphans records whenever report_type equals to scan_finding (4) or license_scanning (2)
# rubocop: disable CodeReuse/ActiveRecord
class DeleteOrphansApprovalProjectRules2 < BatchedMigrationJob
LICENSE_SCANNING_REPORT_TYPE = 2
SCAN_FINDING_REPORT_TYPE = 4
scope_to ->(relation) {
relation.where(report_type: [LICENSE_SCANNING_REPORT_TYPE, SCAN_FINDING_REPORT_TYPE],
security_orchestration_policy_configuration_id: nil)
}
operation_name :delete_all
feature_category :database
# rubocop: disable Style/Documentation
class ApprovalMergeRequestRuleSource < ::ApplicationRecord
# rubocop: enable Style/Documentation
self.table_name = 'approval_merge_request_rule_sources'
end
def perform
each_sub_batch do |sub_batch|
ApprovalMergeRequestRuleSource
.where(approval_project_rule_id: sub_batch.distinct.select(:id))
.delete_all
sub_batch.delete_all
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
|