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

20211028100843_delete_issue_merge_request_taggings_records.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a53f5a4fc25eb2a521be4af2d48ee6219206b14a (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 DeleteIssueMergeRequestTaggingsRecords < Gitlab::Database::Migration[1.0]
  disable_ddl_transaction!

  INDEX_NAME = 'tmp_index_taggings_on_id_where_taggable_type_issue_mr'

  BATCH_SIZE = 3_000
  TAGGABLE_TYPES = %w(Issue MergeRequest)

  class Tagging < ActiveRecord::Base
    self.table_name = "taggings"
  end

  def up
    sleep 2 while Tagging.where(taggable_type: TAGGABLE_TYPES).limit(BATCH_SIZE).delete_all > 0

    remove_concurrent_index_by_name :taggings, INDEX_NAME
  end

  def down
  end
end