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

destroy_invalid_members.rb « background_migration « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7d78795bea96cbcb0ba68cd115a103a75425ccfa (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

module Gitlab
  module BackgroundMigration
    class DestroyInvalidMembers < Gitlab::BackgroundMigration::BatchedMigrationJob # rubocop:disable Style/Documentation
      scope_to ->(relation) { relation.where(member_namespace_id: nil) }

      def perform
        each_sub_batch(operation_name: :delete_all) do |sub_batch|
          deleted_members_data = sub_batch.map do |m|
            { id: m.id, source_id: m.source_id, source_type: m.source_type }
          end

          deleted_count = sub_batch.delete_all

          Gitlab::AppLogger.info({ message: 'Removing invalid member records',
                                   deleted_count: deleted_count,
                                   deleted_member_data: deleted_members_data })
        end
      end
    end
  end
end