Handle orphans when removing soft deleted groups
This fixes the migration from https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7528 so it handles orphans as mentioned in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7528/diffs#note_18800962.
This needs to go in 8.14.0 as otherwise customers may run into the same problem.