blob: 592ef3220ff69bd7c3589b729ddbcf559dffce5d (
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
|
# frozen_string_literal: true
module Gitlab
module BackgroundMigration
# A job to nullify `projects.creator_id` column of projects who creator
# does not exist in `users` table anymore.
class NullifyCreatorIdColumnOfOrphanedProjects < BatchedMigrationJob
scope_to ->(relation) do
relation.where.not(creator_id: nil)
.joins('LEFT OUTER JOIN users ON users.id = projects.creator_id')
.where(users: { id: nil })
end
operation_name :update_all
feature_category :projects
def perform
each_sub_batch do |sub_batch|
sub_batch.update_all(creator_id: nil)
end
end
end
end
end
|