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

backfill_design_management_repositories.rb « background_migration « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fe57767a6932f10e54a3396501fdb01c4f80ed94 (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
25
26
27
28
29
# frozen_string_literal: true

module Gitlab
  module BackgroundMigration
    # Backfill design_management_repositories table for a range of projects
    class BackfillDesignManagementRepositories < BatchedMigrationJob
      operation_name :backfill_design_management_repositories
      feature_category :geo_replication

      def perform
        each_sub_batch do |sub_batch|
          backfill_design_management_repositories(sub_batch)
        end
      end

      def backfill_design_management_repositories(relation)
        connection.execute(
          <<~SQL
          INSERT INTO design_management_repositories (project_id, created_at, updated_at)
            SELECT projects.id, now(), now()
            FROM projects
            WHERE projects.id IN(#{relation.select(:id).to_sql})
          ON CONFLICT (project_id) DO NOTHING;
        SQL
        )
      end
    end
  end
end