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

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

class FinalizeBackfillNullNoteDiscussionIds < Gitlab::Database::Migration[2.0]
  MIGRATION = 'BackfillNoteDiscussionId'
  BATCH_SIZE = 10_000

  restrict_gitlab_migration gitlab_schema: :gitlab_main

  disable_ddl_transaction!

  def up
    Gitlab::BackgroundMigration.steal(MIGRATION)

    define_batchable_model('notes').where(discussion_id: nil).each_batch(of: BATCH_SIZE) do |batch|
      range = batch.pluck('MIN(id)', 'MAX(id)').first

      Gitlab::BackgroundMigration::BackfillNoteDiscussionId.new.perform(*range)
    end
  end

  def down
  end
end