Skip to content
Snippets Groups Projects
Commit c4ac359c authored by ko_oler's avatar ko_oler
Browse files

правки по ПР

parent 1a522725
No related branches found
No related tags found
No related merge requests found
......@@ -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)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment