1
0

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.
This commit is contained in:
kolaente 2024-07-17 10:05:59 +02:00
parent 58e492872a
commit ecdb03aca8
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B

View File

@ -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
}