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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb')
-rw-r--r--db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb b/db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb
new file mode 100644
index 00000000000..f11846ebe1d
--- /dev/null
+++ b/db/post_migrate/20220524074947_finalize_backfill_null_note_discussion_ids.rb
@@ -0,0 +1,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