From 1411db77e001893f2a3a827fed66fd2e8c6d994b Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Thu, 13 Nov 2014 18:19:49 +0900 Subject: [PATCH] Project: Fix server error while deleting Fix a bug that a referential integiry exception occurrs while deleting a project which has an issue to which a label is attached. Delete issues first because labels cannot be deleted if there is an issue refers them. --- app/models/Project.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/Project.java b/app/models/Project.java index 4561ef0ef..76a06703a 100644 --- a/app/models/Project.java +++ b/app/models/Project.java @@ -609,14 +609,16 @@ public void delete() { label.update(); } - for(IssueLabelCategory category : IssueLabelCategory.findByProject(this)) { - category.delete(); - } - + // Issues must be deleted before issue labels because issues may refer + // issue labels. for(Issue issue : issues) { issue.delete(); } + for(IssueLabelCategory category : IssueLabelCategory.findByProject(this)) { + category.delete(); + } + for (Assignee assignee : assignees) { assignee.delete(); }