summaryrefslogtreecommitdiff
path: root/db/post_migrate/20220420061450_backfill_null_note_discussion_ids.rb
blob: 8880bc2f748da4ce25165a37564e0cd068647b1d (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
31
# frozen_string_literal: true

class BackfillNullNoteDiscussionIds < Gitlab::Database::Migration[2.0]
  MIGRATION = 'BackfillNoteDiscussionId'
  DELAY_INTERVAL = 2.minutes
  BATCH_SIZE = 10_000

  restrict_gitlab_migration gitlab_schema: :gitlab_main

  disable_ddl_transaction!

  class Note < MigrationRecord
    include EachBatch

    self.table_name = 'notes'
    self.inheritance_column = :_type_disabled
  end

  def up
    queue_background_migration_jobs_by_range_at_intervals(
      Note.where(discussion_id: nil),
      MIGRATION,
      DELAY_INTERVAL,
      batch_size: BATCH_SIZE
    )
  end

  def down
    # no-op
  end
end