Delete empty fork networks
What does this MR do?
In this branch we make sure we clean up the ForkNetwork
when the last member is unlinked.
There's also a migration that cleans up already orphaned fork_networks
rows.
Why was this MR needed?
Otherwise we'd leave unused rows in the fork_networks
table.
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Tests added for this feature/bug - Review
-
Has been reviewed by Backend -
Has been reviewed by Database
-
Database Checklist
When adding migrations:
-
Updated db/schema.rb
-
Added a down
method so the migration can be reverted -
Added the output of the migration(s) to the MR body
== 20171114104051 RemoveEmptyForkNetworks: migrating ==========================
-- Deleting empty ForkNetworks in batches
-- Deleted 10000 rows in batch
== 20171114104051 RemoveEmptyForkNetworks: migrated (0.0065s) =================
Background migrations print:
Gitlab::BackgroundMigration::DeleteEmptyForkNetworksRange - Deleting empty fork networks in range: 2 - 3
-
Added the execution time of the migration(s) to the MR body:
Requested number of affected fork networks in https://gitlab.com/gitlab-com/infrastructure/issues/3218
Only 119/45880 rows will be deleted. Deleting 930116 rows took 7.9916s locally.
-
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