summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorToon Claes <toon@iotcl.com>2017-08-16 14:46:26 +0200
committerToon Claes <toon@iotcl.com>2017-08-22 14:29:54 +0200
commit2074f39a47645b5ea453adfba84247f2fcc4f3c7 (patch)
tree3f2aab56177cf0704faa8d739ce61acc7055a99e /app
parentce89c425fe51d2317322350bbd8a364c08d97d21 (diff)
downloadgitlab-ce-2074f39a47645b5ea453adfba84247f2fcc4f3c7.tar.gz
Migration to remove pending delete projects with non-existing namespace
There might be some projects where the namespace was removed, but the project wasn't. For these the projects still have a `namespace_id` set. So this adds a post-deploy migration remove all projects that are pending delete, and have a `namespace_id` that is non-existing.
Diffstat (limited to 'app')
-rw-r--r--app/workers/namespaceless_project_destroy_worker.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/workers/namespaceless_project_destroy_worker.rb b/app/workers/namespaceless_project_destroy_worker.rb
index a9073742ff7..b148e7082b3 100644
--- a/app/workers/namespaceless_project_destroy_worker.rb
+++ b/app/workers/namespaceless_project_destroy_worker.rb
@@ -18,7 +18,8 @@ class NamespacelessProjectDestroyWorker
rescue ActiveRecord::RecordNotFound
return
end
- return unless project.namespace_id.nil? # Reject doing anything for projects that *do* have a namespace
+
+ return if namespace?(project) # Reject doing anything for projects that *do* have a namespace
project.team.truncate
@@ -29,6 +30,10 @@ class NamespacelessProjectDestroyWorker
private
+ def namespace?(project)
+ project.namespace_id && Namespace.exists?(project.namespace_id)
+ end
+
def unlink_fork(project)
merge_requests = project.forked_from_project.merge_requests.opened.from_project(project)