From d842060bc421322064c01818c4b1422b1f179137 Mon Sep 17 00:00:00 2001 From: black Date: Tue, 27 Jun 2023 19:06:05 +0800 Subject: [PATCH] add comment --- schema/field.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/schema/field.go b/schema/field.go index 8df568ab..04be47cf 100644 --- a/schema/field.go +++ b/schema/field.go @@ -69,7 +69,6 @@ type Field struct { DefaultValueInterface interface{} NotNull bool Unique bool - UniqueIndex string Comment string Size int Precision int @@ -88,6 +87,12 @@ type Field struct { Set func(context.Context, reflect.Value, interface{}) error Serializer SerializerInterface NewValuePool FieldNewValuePool + + // In some db (e.g. MySQL), Unique and UniqueIndex are indistinguishable. + // When a column has a (not Mul) UniqueIndex, Migrator always reports its gorm.ColumnType is Unique. + // It causes field unnecessarily migration. + // Therefore, we need to record the UniqueIndex on this column (exclude Mul UniqueIndex) for MigrateColumnUnique. + UniqueIndex string } func (field *Field) BindName() string {