blob: a2c9354e430e16cf75f1b24755881eeb096c6c4a (
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
36
37
38
|
module Gitlab
module Database
module RenameReservedPathsMigration
module Projects
include Gitlab::ShellAdapter
def rename_projects(paths)
projects_for_paths(paths).each do |project|
rename_project(project)
end
end
def rename_project(project)
old_full_path, new_full_path = rename_path_for_routable(project)
move_repository(project, old_full_path, new_full_path)
move_repository(project, "#{old_full_path}.wiki", "#{new_full_path}.wiki")
move_uploads(old_full_path, new_full_path)
move_pages(old_full_path, new_full_path)
end
def move_repository(project, old_path, new_path)
unless gitlab_shell.mv_repository(project.repository_storage_path,
old_path,
new_path)
Rails.logger.error "Error moving #{old_path} to #{new_path}"
end
end
def projects_for_paths(paths)
with_paths = MigrationClasses::Project.arel_table[:path]
.matches_any(paths)
MigrationClasses::Project.where(with_paths)
end
end
end
end
end
|