Add migration to remove pending delete projects with non-existing namespace
What does this MR do?
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.
This is a follow-up of !11044 (merged).
Database Checklist
When adding migrations:
-
Updated db/schema.rb
-
Added a down
method so the migration can be reverted.
=> NOOP -
Added the output of the migration(s) to the MR body => On production 129
rows would be affected, see https://gitlab.com/gitlab-com/infrastructure/issues/2548#note_38245210 -
Added the execution time of the migration(s) to the MR body => On staging it took 0.24ms
, see https://gitlab.com/gitlab-com/infrastructure/issues/2548#note_38222879 -
Added tests for the migration in spec/migrations
if necessary (e.g. when migrating data) -
Made sure the migration won't interfere with a running GitLab cluster, for example by disabling transactions for long running migrations
When adding or modifying queries to improve performance:
-
Included the raw SQL queries of the relevant queries:
=> Query generated byCleanupNonexistingNamespacePendingDeleteProjects#find_batch
SELECT "projects"."id" FROM "projects" WHERE "projects"."pending_delete" = 't' AND (NOT (EXISTS (SELECT 1 FROM "namespaces" WHERE "namespaces"."id" = "projects"."namespace_id")))
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated -
API support added -
Tests added for this feature/bug - Review
-
Has been reviewed by UX -
Has been reviewed by Frontend -
Has been reviewed by Backend -
Has been reviewed by Database
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Squashed related commits together
What are the relevant issue numbers?
Closes gitlab-org/gitlab-ce#36541.
Edited by Toon Claes