From c4ac359cb01bf7d2b52a3df3827615dd3bc5602c Mon Sep 17 00:00:00 2001 From: ko_oler <kooler89@gmail.com> Date: Fri, 21 Jul 2023 09:56:54 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=9F=D0=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/setup/collection.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/setup/collection.go b/pkg/setup/collection.go index cfd6e3f7..7f2e1821 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) } -- GitLab