blob: 74f5bc3f7257c9a47a8df2012db6b620c2632007 (
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 :groups_and_projects
def perform
each_sub_batch do |sub_batch|
sub_batch.update_all(creator_id: nil)
end
end
end
end
end
|