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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20200416111111_migrate_vulnerability_dismissals.rb')
-rw-r--r--db/post_migrate/20200416111111_migrate_vulnerability_dismissals.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/db/post_migrate/20200416111111_migrate_vulnerability_dismissals.rb b/db/post_migrate/20200416111111_migrate_vulnerability_dismissals.rb
new file mode 100644
index 00000000000..6ec8b991968
--- /dev/null
+++ b/db/post_migrate/20200416111111_migrate_vulnerability_dismissals.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+class MigrateVulnerabilityDismissals < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ MIGRATION = 'UpdateVulnerabilitiesToDismissed'.freeze
+ BATCH_SIZE = 500
+ DELAY_INTERVAL = 2.minutes.to_i
+
+ class Vulnerability < ActiveRecord::Base
+ self.table_name = 'vulnerabilities'
+ self.inheritance_column = :_type_disabled
+
+ include ::EachBatch
+ end
+
+ def up
+ return unless Gitlab.ee?
+
+ Vulnerability.select('project_id').group(:project_id).each_batch(of: BATCH_SIZE, column: "project_id") do |project_batch, index|
+ batch_delay = (index - 1) * BATCH_SIZE * DELAY_INTERVAL
+
+ project_batch.each_with_index do |project, project_batch_index|
+ project_delay = project_batch_index * DELAY_INTERVAL
+ migrate_in(batch_delay + project_delay, MIGRATION, project[:project_id])
+ end
+ end
+ end
+
+ def down
+ # nothing to do
+ end
+end