summaryrefslogtreecommitdiff
path: root/db/post_migrate/20210511095658_schedule_migrate_project_taggings_context_from_tags_to_topics.rb
blob: 25d23b771d5c89ce975b43a17a7d084166399fc5 (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
30
# frozen_string_literal: true

class ScheduleMigrateProjectTaggingsContextFromTagsToTopics < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  BATCH_SIZE = 30_000
  DELAY_INTERVAL = 2.minutes
  MIGRATION = 'MigrateProjectTaggingsContextFromTagsToTopics'

  disable_ddl_transaction!

  class Tagging < ActiveRecord::Base
    include ::EachBatch

    self.table_name = 'taggings'
  end

  def up
    queue_background_migration_jobs_by_range_at_intervals(
      Tagging.where(taggable_type: 'Project', context: 'tags'),
      MIGRATION,
      DELAY_INTERVAL,
      batch_size: BATCH_SIZE
    )
  end

  def down
  end
end