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

20200211155000_cleanup_empty_merge_request_mentions.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e90d192388b687f0f8d9b04531fec491cf67ff6e (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
# frozen_string_literal: true

class CleanupEmptyMergeRequestMentions < ActiveRecord::Migration[5.2]
  DOWNTIME = false
  BATCH_SIZE = 1_000

  class MergeRequestUserMention < ActiveRecord::Base
    include EachBatch

    self.table_name = 'merge_request_user_mentions'
  end

  def up
    # cleanup merge request user mentions with no actual mentions,
    # re https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24586#note_285982468
    MergeRequestUserMention
      .where(mentioned_users_ids: nil)
      .where(mentioned_groups_ids: nil)
      .where(mentioned_projects_ids: nil).each_batch(of: BATCH_SIZE) do |batch|
      batch.delete_all
    end
  end

  def down
    # no-op
  end
end