diff options
author | Bob Van Landuyt <bob@gitlab.com> | 2017-04-18 18:16:48 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@gitlab.com> | 2017-05-01 12:14:24 +0300 |
commit | 389057f00184a3549a1874174cbb81c807abfd49 (patch) | |
tree | 092e76a6b3939edf26b69f2ab5acd1ca59ada691 /lib/gitlab | |
parent | e50f4bc066e4477e9c59708f978383b071dc2959 (diff) |
Rename Projects & Namespaces based on entire paths
Diffstat (limited to 'lib/gitlab')
3 files changed, 13 insertions, 8 deletions
diff --git a/lib/gitlab/database/rename_reserved_paths_migration/rename_base.rb b/lib/gitlab/database/rename_reserved_paths_migration/rename_base.rb index 367348a9a42..4d454fd8ea0 100644 --- a/lib/gitlab/database/rename_reserved_paths_migration/rename_base.rb +++ b/lib/gitlab/database/rename_reserved_paths_migration/rename_base.rb @@ -13,6 +13,10 @@ module Gitlab @migration = migration end + def path_patterns + @path_patterns ||= paths.map { |path| "%#{path}" } + end + def rename_path_for_routable(routable) old_path = routable.path old_full_path = routable.full_path diff --git a/lib/gitlab/database/rename_reserved_paths_migration/rename_namespaces.rb b/lib/gitlab/database/rename_reserved_paths_migration/rename_namespaces.rb index 80e8135ea93..847b6e56955 100644 --- a/lib/gitlab/database/rename_reserved_paths_migration/rename_namespaces.rb +++ b/lib/gitlab/database/rename_reserved_paths_migration/rename_namespaces.rb @@ -16,9 +16,9 @@ module Gitlab elsif type == :top_level MigrationClasses::Namespace.where(parent_id: nil) end - with_paths = MigrationClasses::Namespace.arel_table[:path]. - matches_any(paths) - namespaces.where(with_paths) + with_paths = MigrationClasses::Route.arel_table[:path]. + matches_any(path_patterns) + namespaces.joins(:route).where(with_paths) end def rename_namespace(namespace) @@ -43,8 +43,8 @@ module Gitlab end def repo_paths_for_namespace(namespace) - projects_for_namespace(namespace). - select('distinct(repository_storage)').map(&:repository_storage_path) + projects_for_namespace(namespace).distinct.select(:repository_storage). + map(&:repository_storage_path) end def projects_for_namespace(namespace) diff --git a/lib/gitlab/database/rename_reserved_paths_migration/rename_projects.rb b/lib/gitlab/database/rename_reserved_paths_migration/rename_projects.rb index 02f10d8e951..49b9453b134 100644 --- a/lib/gitlab/database/rename_reserved_paths_migration/rename_projects.rb +++ b/lib/gitlab/database/rename_reserved_paths_migration/rename_projects.rb @@ -28,9 +28,10 @@ module Gitlab end def projects_for_paths - with_paths = MigrationClasses::Project.arel_table[:path] - .matches_any(paths) - MigrationClasses::Project.where(with_paths) + with_paths = MigrationClasses::Route.arel_table[:path] + .matches_any(path_patterns) + + MigrationClasses::Project.joins(:route).where(with_paths) end end end |