From d310b80808d16684d080e54b9bbaf58212c1215d Mon Sep 17 00:00:00 2001
From: Alena Petraki <alena.petraki@gmail.com>
Date: Mon, 30 Oct 2023 18:07:21 +0300
Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?=
 =?UTF-8?q?=D0=BD=D0=B0=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20?=
 =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=81=D1=80=D0=B0=D0=B2=D0=BD=D0=B5=D0=BD?=
 =?UTF-8?q?=D0=B8=D1=8F=20=D1=81=D1=85=D0=B5=D0=BC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 pkg/schema/schema.go    | 11 +++++++++++
 pkg/setup/collection.go |  5 ++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/pkg/schema/schema.go b/pkg/schema/schema.go
index bac95d05..6b26f336 100644
--- a/pkg/schema/schema.go
+++ b/pkg/schema/schema.go
@@ -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
diff --git a/pkg/setup/collection.go b/pkg/setup/collection.go
index a42c650d..725a04e3 100644
--- a/pkg/setup/collection.go
+++ b/pkg/setup/collection.go
@@ -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
 }
-- 
GitLab