diff --git a/pkg/setup/collection.go b/pkg/setup/collection.go index cfd6e3f773939e4207a373f41f5f94e93a1a5451..7f2e1821725bbd9632e383c322af99fb51c6ec8a 100644 --- a/pkg/setup/collection.go +++ b/pkg/setup/collection.go @@ -10,6 +10,7 @@ import ( "git.perx.ru/perxis/perxis-go/pkg/environments" "git.perx.ru/perxis/perxis-go/pkg/errors" "git.perx.ru/perxis/perxis-go/pkg/extension" + "git.perx.ru/perxis/perxis-go/pkg/schema" "go.uber.org/zap" ) @@ -75,13 +76,13 @@ func DeleteCollectionIfRemove() CollectionsOption { } } -func isCollsSchemaMetadataEqual(collection, exist *collections.Collection) bool { - if collection.Schema.Metadata == nil && exist.Schema.Metadata == nil { +func isCollsSchemaMetadataEqual(s1, s2 *schema.Schema) bool { + if s1.Metadata == nil && s2.Metadata == nil { return true } - if collection.Schema.Metadata != nil && collection.Schema.Metadata[extension.ExtensionMetadataKey] != "" { - if exist.Schema.Metadata == nil || exist.Schema.Metadata[extension.ExtensionMetadataKey] != collection.Schema.Metadata[extension.ExtensionMetadataKey] { + if s1.Metadata != nil && s1.Metadata[extension.ExtensionMetadataKey] != "" { + if s2.Metadata == nil || s2.Metadata[extension.ExtensionMetadataKey] != s1.Metadata[extension.ExtensionMetadataKey] { return false } } @@ -92,7 +93,7 @@ func isCollsSchemaMetadataEqual(collection, exist *collections.Collection) bool func DefaultUpdateCollectionStrategy() CollectionsOption { return func(c *CollectionConfig) { c.UpdateFn = func(s *Setup, exist, collection *collections.Collection) (*collections.Collection, bool, bool, error) { - if !alwaysSetSchema && !s.IsForce() && !collection.IsView() && !exist.IsView() && !isCollsSchemaMetadataEqual(collection, exist) { + if !alwaysSetSchema && !s.IsForce() && !collection.IsView() && !exist.IsView() && !isCollsSchemaMetadataEqual(collection.Schema, exist.Schema) { return nil, false, false, errors.WithDetailf(collections.ErrAlreadyExists, "Коллекция с идентификатором '%s' "+ "уже существует. Удалите ее или вызовите установку расширения с флагом Force", collection.ID) }