diff options
author | Bob Van Landuyt <bob@gitlab.com> | 2017-06-06 19:40:11 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-06-26 18:49:30 +0300 |
commit | 152cba56e4004de1b1c2accee77e40a019d8c667 (patch) | |
tree | 843193a71aecebeedcedc8cf92de349196d41072 /lib/gitlab/database | |
parent | 0faff42d7cc62dba50ca99ab1bc034c285311409 (diff) |
Revert namespace renames
Diffstat (limited to 'lib/gitlab/database')
-rw-r--r-- | lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb | 21 | ||||
-rw-r--r-- | lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb | 3 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb index a84af02e67b..434167b0f88 100644 --- a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb +++ b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb @@ -28,6 +28,10 @@ module Gitlab track_rename('namespace', old_full_path, new_full_path) + rename_namespace_dependencies(namespace, old_full_path, new_full_path) + end + + def rename_namespace_dependencies(namespace, old_full_path, new_full_path) move_repositories(namespace, old_full_path, new_full_path) move_uploads(old_full_path, new_full_path) move_pages(old_full_path, new_full_path) @@ -35,6 +39,23 @@ module Gitlab remove_cached_html_for_projects(projects_for_namespace(namespace).map(&:id)) end + def revert_renames + reverts_for_type('namespace') do |path_before_rename, current_path| + matches_path = MigrationClasses::Route.arel_table[:path].matches(current_path) + namespace = MigrationClasses::Namespace.joins(:route) + .where(matches_path).first.becomes(MigrationClasses::Namespace) + + if namespace + perform_rename(namespace, current_path, path_before_rename) + + rename_namespace_dependencies(namespace, current_path, path_before_rename) + else + say "Couldn't rename namespace##{namespace.id} from #{current_path} "\ + " back to #{path_before_rename}, namespace no longer exists" + end + end + end + def rename_user(old_username, new_username) MigrationClasses::User.where(username: old_username) .update_all(username: new_username) diff --git a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb index 1d2a41d91bb..061f531f1d5 100644 --- a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb +++ b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb @@ -38,7 +38,8 @@ module Gitlab move_project_folders(project, current_path, path_before_rename) else - say "Couldn't rename project##{project.id} from #{current_path} back to #{path_before_rename}, project no longer exists" + say "Couldn't rename project##{project.id} from #{current_path} "\ + "back to #{path_before_rename}, project no longer exists" end end end |