2022-11-25 23:54:43 +05:30
|
|
|
# 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) }
|
2023-01-13 00:05:48 +05:30
|
|
|
operation_name :delete_all
|
2023-03-17 16:20:25 +05:30
|
|
|
feature_category :database
|
2022-11-25 23:54:43 +05:30
|
|
|
|
|
|
|
def perform
|
2023-01-13 00:05:48 +05:30
|
|
|
each_sub_batch do |sub_batch|
|
2022-11-25 23:54:43 +05:30
|
|
|
deleted_members_data = sub_batch.map do |m|
|
2023-01-13 00:05:48 +05:30
|
|
|
{ id: m.id, source_id: m.source_id, source_type: m.source_type, access_level: m.access_level }
|
2022-11-25 23:54:43 +05:30
|
|
|
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
|