Commit 3730d89f authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'bvl-fork-network-memberships-for-deleted-source' into 'master'

Don't try to create fork network memberships for forks of forks

Closes #40072

See merge request gitlab-org/gitlab-ce!15366
parents fb7abd87 aaf18bb8
---
title: Don't try to create fork network memberships for forks with a missing source
merge_request: 15366
author:
type: fixed
......@@ -51,10 +51,20 @@ module Gitlab
FROM projects
WHERE forked_project_links.forked_from_project_id = projects.id
)
AND NOT EXISTS (
SELECT true
FROM forked_project_links AS parent_links
WHERE parent_links.forked_to_project_id = forked_project_links.forked_from_project_id
AND NOT EXISTS (
SELECT true
FROM projects
WHERE parent_links.forked_from_project_id = projects.id
)
)
AND forked_project_links.id BETWEEN #{start_id} AND #{end_id}
MISSING_MEMBERS
ForkNetworkMember.count_by_sql(count_sql) > 0
ForkedProjectLink.count_by_sql(count_sql) > 0
end
def log(message)
......
......@@ -93,7 +93,14 @@ describe Gitlab::BackgroundMigration::CreateForkNetworkMembershipsRange, :migrat
end
it 'knows it is finished for this range' do
expect(migration.missing_members?(1, 7)).to be_falsy
expect(migration.missing_members?(1, 8)).to be_falsy
end
it 'does not miss members for forks of forks for which the root was deleted' do
forked_project_links.create(id: 9, forked_from_project_id: base1_fork1.id, forked_to_project_id: create(:project).id)
base1.destroy
expect(migration.missing_members?(7, 10)).to be_falsy
end
context 'with more forks' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment