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

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

module Gitlab
  module BackgroundMigration
    # The class to migrate the context of project taggings from `tags` to `topics`
    class MigrateProjectTaggingsContextFromTagsToTopics
      # Temporary AR table for taggings
      class Tagging < ActiveRecord::Base
        include EachBatch

        self.table_name = 'taggings'
      end

      def perform(start_id, stop_id)
        Tagging.where(taggable_type: 'Project', context: 'tags', id: start_id..stop_id).each_batch(of: 500) do |relation|
          relation.update_all(context: 'topics')
        end
      end
    end
  end
end