Regularly track orphaned, soft-deleted projects and namespaces
We have seen a number of regressions with projects being in this state, where users can't remove the existing namespace because the project is not actually deleted properly (see gitlab-org/gitlab-ce#20984).
We should regularly measure in our database for certain counts. I suggest we monitor the following Rails commands:
-
Orphaned projects:
Project.unscoped.where(namespace_id: nil).count
-
Soft-deleted projects:
Project.unscoped.where(pending_delete: true).count
-
Orphaned projects with non-existent namespace:
Project.unscoped.includes(:namespace).where(pending_delete: true).where(namespaces: {id: nil}).count