test deleteMissing with schema changes

This commit is contained in:
Gani Georgiev
2022-08-10 13:22:27 +03:00
parent ac0c23ff64
commit 65b830198b
15 changed files with 488 additions and 136 deletions
+10 -1
View File
@@ -190,7 +190,7 @@ func (dao *Dao) ImportCollections(
mappedImported := make(map[string]*models.Collection, len(importedCollections))
for _, imported := range importedCollections {
// normalize
// normalize ids
if !imported.HasId() {
// generate id if not set
imported.MarkAsNew()
@@ -199,6 +199,15 @@ func (dao *Dao) ImportCollections(
imported.MarkAsNew()
}
// extend existing schema
if existing, ok := mappedExisting[imported.GetId()]; ok && !deleteMissing {
schema, _ := existing.Schema.Clone()
for _, f := range imported.Schema.Fields() {
schema.AddField(f) // add or replace
}
imported.Schema = *schema
}
mappedImported[imported.GetId()] = imported
}