From c19ac41b34fa327aee3e10cb01bfbe539b32705d Mon Sep 17 00:00:00 2001 From: zeripath Date: Thu, 5 Mar 2020 13:56:53 +0000 Subject: [PATCH] Delete dependencies when deleting a repository (#10608) (#10616) Co-authored-by: zeripath Co-authored-by: Lauris BH Co-authored-by: Lauris BH Co-authored-by: zeripath --- models/repo.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/models/repo.go b/models/repo.go index 804320a2b..ed44a5e68 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1856,6 +1856,18 @@ func DeleteRepository(doer *User, uid, repoID int64) error { return err } + // Dependencies for issues in this repository + if _, err = sess.In("issue_id", deleteCond). + Delete(&IssueDependency{}); err != nil { + return err + } + + // Delete dependencies for issues in other repositories + if _, err = sess.In("dependency_id", deleteCond). + Delete(&IssueDependency{}); err != nil { + return err + } + if _, err = sess.In("issue_id", deleteCond). Delete(&IssueUser{}); err != nil { return err