summaryrefslogtreecommitdiff
path: root/lib/gitlab/background_migration/backfill_namespace_settings.rb
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