summaryrefslogtreecommitdiff
path: root/db/migrate/20220208171826_update_default_scan_method_of_dast_site_profile.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20220208171826_update_default_scan_method_of_dast_site_profile.rb')
-rw-r--r--db/migrate/20220208171826_update_default_scan_method_of_dast_site_profile.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/db/migrate/20220208171826_update_default_scan_method_of_dast_site_profile.rb b/db/migrate/20220208171826_update_default_scan_method_of_dast_site_profile.rb
new file mode 100644
index 00000000000..b01dbe642e2
--- /dev/null
+++ b/db/migrate/20220208171826_update_default_scan_method_of_dast_site_profile.rb
@@ -0,0 +1,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