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

backfill_topics_title.rb « background_migration « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 19a1eff5b58a4a3a437dff22022bb1ce3e1fc4b3 (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
# frozen_string_literal: true

module Gitlab
  module BackgroundMigration
    # The class to backfill the topic title
    class BackfillTopicsTitle
      # Temporary AR model for topics
      class Topic < ActiveRecord::Base
        self.table_name = 'topics'
      end

      def perform(start_id, end_id)
        Topic.where(id: start_id..end_id).where(title: nil).update_all('title = name')

        mark_job_as_succeeded(start_id, end_id)
      end

      private

      def mark_job_as_succeeded(*arguments)
        ::Gitlab::Database::BackgroundMigrationJob.mark_all_as_succeeded(
          self.class.name.demodulize,
          arguments
        )
      end
    end
  end
end