Skip to content

Commit

Permalink
WIP - Fix second issue
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSisley committed Sep 26, 2024
1 parent c186b7f commit 134fcc1
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions internal/db/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,6 @@ func (db *db) updateSchema(
return err
}

oldDefs := make([]client.CollectionDefinition, 0, len(allExistingCols))
for _, col := range allExistingCols {
oldDefs = append(oldDefs, col.Definition())
}

for _, schema := range proposedDescriptionsByName {
previousSchema := existingSchemaByName[schema.Name]

Expand Down Expand Up @@ -498,7 +493,25 @@ func (db *db) updateSchema(
return err
}

err = db.validateSchemaUpdate(ctx, oldDefs, definitions)
oldDefs := make([]client.CollectionDefinition, 0, len(allExistingCols))
for _, col := range allExistingCols {
oldDefs = append(oldDefs, col.Definition())
}

defNames := make(map[string]struct{}, len(definitions))
for _, def := range definitions {
defNames[def.GetName()] = struct{}{}
}

newDefs := make([]client.CollectionDefinition, 0, len(definitions))
newDefs = append(newDefs, definitions...)
for _, existing := range allExistingCols {
if _, ok := defNames[existing.Definition().GetName()]; !ok {
newDefs = append(newDefs, existing.Definition())
}
}

err = db.validateSchemaUpdate(ctx, oldDefs, newDefs)
if err != nil {
return err
}
Expand Down

0 comments on commit 134fcc1

Please sign in to comment.