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:
parent
58e492872a
commit
ecdb03aca8
@ -285,9 +285,6 @@ func createProjectWithEverything(s *xorm.Session, project *models.ProjectWithTas
|
|||||||
|
|
||||||
newTaskIDs = append(newTaskIDs, t.ID)
|
newTaskIDs = append(newTaskIDs, t.ID)
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
tasksByOldID[oldid] = t
|
tasksByOldID[oldid] = t
|
||||||
|
|
||||||
log.Debugf("[creating structure] Created task %d", t.ID)
|
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
|
// First create the related tasks if they do not exist
|
||||||
if _, exists := tasksByOldID[rt.ID]; !exists || rt.ID == 0 {
|
if _, exists := tasksByOldID[rt.ID]; !exists || rt.ID == 0 {
|
||||||
oldid := rt.ID
|
oldid := rt.ID
|
||||||
err = setBucketOrDefault(rt)
|
rt.ProjectID = t.ProjectID
|
||||||
|
err = rt.Create(s, user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rt.ProjectID = t.ProjectID
|
err = setBucketOrDefault(rt)
|
||||||
err = rt.Create(s, user)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user