Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20230501165244_remove_software_license_policies_without_scan_result_policy_id.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0e3b15a933c573e99cd0342c8d9022dde3663bbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

class RemoveSoftwareLicensePoliciesWithoutScanResultPolicyId < Gitlab::Database::Migration[2.1]
  disable_ddl_transaction!

  restrict_gitlab_migration gitlab_schema: :gitlab_main

  BATCH_SIZE = 1000

  def up
    each_batch_range('software_license_policies',
      scope: ->(table) { table.where(scan_result_policy_id: nil) },
      of: BATCH_SIZE) do |min, max|
      execute("DELETE FROM software_license_policies WHERE id BETWEEN #{min} AND #{max}")
    end
  end

  def down
    # NO-OP
  end
end