Skip to content
Snippets Groups Projects
Commit 9042eebe authored by Pavel Antonov's avatar Pavel Antonov :asterisk:
Browse files

Merge branch 'feature/PRXS-1695-EqualSchemas' into 'master'

Исправлена ошибка, при которой при каждой установке расширения вызывалась установка схем всех коллекций и миграция окружения, даже если схемы не менялись

See merge request perxis/perxis-go!106
parents 08b8edf5 d310b808
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ package schema
import (
"context"
"reflect"
"git.perx.ru/perxis/perxis-go/pkg/errors"
"git.perx.ru/perxis/perxis-go/pkg/expr"
......@@ -40,6 +41,16 @@ func (s *Schema) Clone(reset bool) *Schema {
}
}
func (s *Schema) Equal(sch *Schema) bool {
if s == sch {
return true
}
if s == nil || sch == nil {
return false
}
return reflect.DeepEqual(s.Field, sch.Field)
}
func (s Schema) WithIncludes(includes ...interface{}) *Schema {
s.Field.SetIncludes(includes...)
return &s
......
......@@ -2,7 +2,6 @@ package setup
import (
"context"
"reflect"
"strings"
"git.perx.ru/perxis/perxis-go/pkg/collections"
......@@ -53,7 +52,7 @@ func OverwriteCollection() CollectionsOption {
update := new.Name != old.Name || new.IsSingle() != old.IsSingle() || new.IsSystem() != old.IsSystem() ||
new.IsNoData() != old.IsNoData() || new.Hidden != old.Hidden || new.IsView() != old.IsView() || !data.ElementsMatch(old.Tags, new.Tags)
return new, update, !reflect.DeepEqual(old.Schema, new.Schema), nil
return new, update, old.Schema.Equal(new.Schema), nil
}
}
}
......@@ -91,7 +90,7 @@ func DefaultUpdateCollectionStrategyFn(_ *Setup, exist, collection *collections.
update = update && *exist.View == *collection.View
}
setSchema = !collection.IsView() && !reflect.DeepEqual(exist.Schema, collection.Schema)
setSchema = !collection.IsView() && !exist.Schema.Equal(collection.Schema)
return collection, update, setSchema, nil
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment