summaryrefslogtreecommitdiff
path: root/lib/gitlab/background_migration/backfill_releases_author_id.rb
blob: 8982fe1acca03af34c05ab8a1ab9e8ede6165882 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

module Gitlab
  module BackgroundMigration
    # Backfills releases with empty release authors.
    # More details on:
    # 1) https://gitlab.com/groups/gitlab-org/-/epics/8375
    # 2) https://gitlab.com/gitlab-org/gitlab/-/issues/367522#note_1156503600
    class BackfillReleasesAuthorId < BatchedMigrationJob
      operation_name :backfill_releases_author_id
      job_arguments :ghost_user_id
      feature_category :database

      scope_to ->(relation) { relation.where(author_id: nil) }

      def perform
        each_sub_batch do |sub_batch|
          sub_batch.update_all(author_id: ghost_user_id)
        end
      end
    end
  end
end