summaryrefslogtreecommitdiff
path: root/db/migrate/20220208171826_update_default_scan_method_of_dast_site_profile.rb
blob: b01dbe642e223883b2459b37a434c114940a9111 (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
# frozen_string_literal: true

# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class UpdateDefaultScanMethodOfDastSiteProfile < Gitlab::Database::Migration[1.0]
  BATCH_SIZE = 500

  disable_ddl_transaction!

  def up
    each_batch_range('dast_site_profiles', scope: ->(table) { table.where(target_type: 1) }, of: BATCH_SIZE) do |min, max|
      execute <<~SQL
        UPDATE dast_site_profiles
        SET scan_method = 1
        WHERE id BETWEEN #{min} AND #{max}
      SQL
    end
  end

  def down
    # noop
  end
end