Class: Gitlab::BackgroundMigration::BackfillNoteDiscussionId

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/background_migration/backfill_note_discussion_id.rb

Overview

Fixes notes with NULL discussion_ids due to a bug when importing from GitHub Bug was fixed in gitlab.com/gitlab-org/gitlab/-/merge_requests/76517

Defined Under Namespace

Classes: Note

Constant Summary collapse

SUB_BATCH_SIZE =
300

Instance Method Summary collapse

Instance Method Details

#perform(start_id, stop_id) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/gitlab/background_migration/backfill_note_discussion_id.rb', line 24

def perform(start_id, stop_id)
  notes = Note.select(:id, :noteable_type, :noteable_id, :commit_id)
              .where(discussion_id: nil, id: start_id..stop_id)

  notes.each_batch(of: SUB_BATCH_SIZE) do |relation|
    update_discussion_ids(relation)
  end
end