From ecdb03aca81278f0b30eefb623458a80d4d82e01 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 17 Jul 2024 10:05:59 +0200 Subject: [PATCH] fix(migration): correctly set bucket for related tasks When creating a related task during the import, migrating would fail because the migration would try to add the task to a bucket before the task was created. This fix changes the order in which that happens to prevent the error. --- pkg/modules/migration/create_from_structure.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/modules/migration/create_from_structure.go b/pkg/modules/migration/create_from_structure.go index b764d8a09..1455deadd 100644 --- a/pkg/modules/migration/create_from_structure.go +++ b/pkg/modules/migration/create_from_structure.go @@ -285,9 +285,6 @@ func createProjectWithEverything(s *xorm.Session, project *models.ProjectWithTas newTaskIDs = append(newTaskIDs, t.ID) - if err != nil { - return - } tasksByOldID[oldid] = t log.Debugf("[creating structure] Created task %d", t.ID) @@ -306,12 +303,12 @@ func createProjectWithEverything(s *xorm.Session, project *models.ProjectWithTas // First create the related tasks if they do not exist if _, exists := tasksByOldID[rt.ID]; !exists || rt.ID == 0 { oldid := rt.ID - err = setBucketOrDefault(rt) + rt.ProjectID = t.ProjectID + err = rt.Create(s, user) if err != nil { return } - rt.ProjectID = t.ProjectID - err = rt.Create(s, user) + err = setBucketOrDefault(rt) if err != nil { return }