blob: 06706b729ea96849efde1f0bb83b6c812de7cb7d (
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
28
29
30
31
32
33
34
35
|
# frozen_string_literal: true
# rubocop:disable Style/Documentation
module Gitlab
module BackgroundMigration
class BackfillProjectImportLevel < BatchedMigrationJob
LEVEL = {
Gitlab::Access::NO_ACCESS => [0],
Gitlab::Access::DEVELOPER => [2],
Gitlab::Access::MAINTAINER => [1],
Gitlab::Access::OWNER => [nil]
}.freeze
def perform
each_sub_batch(operation_name: :update_import_level) do |sub_batch|
update_import_level(sub_batch)
end
end
private
def update_import_level(relation)
LEVEL.each do |import_level, creation_level|
namespace_ids = relation
.where(type: 'Group', project_creation_level: creation_level)
NamespaceSetting.where(
namespace_id: namespace_ids
).update_all(project_import_level: import_level)
end
end
end
end
end
# rubocop:enable Style/Documentation
|