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

backfill_namespace_settings.rb « background_migration « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a391d5f4ebedab49faddb119ce141e842eaf95be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

module Gitlab
  module BackgroundMigration
    # Backfillnamespace_settings for a range of namespaces
    class BackfillNamespaceSettings
      def perform(start_id, end_id)
        ActiveRecord::Base.connection.execute <<~SQL
          INSERT INTO namespace_settings (namespace_id, created_at, updated_at)
            SELECT namespaces.id, now(), now()
            FROM namespaces
            WHERE namespaces.id BETWEEN #{start_id} AND #{end_id}
          ON CONFLICT (namespace_id) DO NOTHING;
        SQL
      end
    end
  end
end