1
0

feat(migration): use new structure for migration

This commit is contained in:
kolaente
2022-12-29 18:11:15 +01:00
parent fef253312c
commit 386e218b95
8 changed files with 44 additions and 44 deletions

View File

@ -113,13 +113,13 @@ func (v *FileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) er
return fmt.Errorf("could not read data file: %w", err)
}
namespaces := []*models.NamespaceWithProjectsAndTasks{}
if err := json.Unmarshal(bufData.Bytes(), &namespaces); err != nil {
parent := []*models.ProjectWithTasksAndBuckets{}
if err := json.Unmarshal(bufData.Bytes(), &parent); err != nil {
return fmt.Errorf("could not read data: %w", err)
}
for _, n := range namespaces {
for _, l := range n.Projects {
for _, n := range parent {
for _, l := range n.ChildProjects {
if b, exists := storedFiles[l.BackgroundFileID]; exists {
bf, err := b.Open()
if err != nil {
@ -163,7 +163,7 @@ func (v *FileMigrator) Migrate(user *user.User, file io.ReaderAt, size int64) er
}
}
err = migration.InsertFromStructure(namespaces, user)
err = migration.InsertFromStructure(parent, user)
if err != nil {
return fmt.Errorf("could not insert data: %w", err)
}