summaryrefslogtreecommitdiff
path: root/lib/gitlab/background_migration/populate_latest_pipeline_ids.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/background_migration/populate_latest_pipeline_ids.rb')
-rw-r--r--lib/gitlab/background_migration/populate_latest_pipeline_ids.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/gitlab/background_migration/populate_latest_pipeline_ids.rb b/lib/gitlab/background_migration/populate_latest_pipeline_ids.rb
new file mode 100644
index 00000000000..a2b25a293fe
--- /dev/null
+++ b/lib/gitlab/background_migration/populate_latest_pipeline_ids.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+# rubocop: disable Style/Documentation
+module Gitlab
+ module BackgroundMigration
+ class PopulateLatestPipelineIds
+ class ProjectSetting < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'project_settings'
+
+ scope :in_range, -> (start_id, end_id) { where(id: start_id..end_id) }
+ scope :has_vulnerabilities_without_latest_pipeline_set, -> do
+ joins('LEFT OUTER JOIN vulnerability_statistics vs ON vs.project_id = project_settings.project_id')
+ .where(vs: { latest_pipeline_id: nil })
+ .where('has_vulnerabilities IS TRUE')
+ end
+ end
+
+ def perform(start_id, end_id)
+ # no-op
+ end
+ end
+ end
+end
+
+Gitlab::BackgroundMigration::PopulateLatestPipelineIds.prepend_mod