From 9c5ca8130e0db6454b324c0202c8793dfcabf2b3 Mon Sep 17 00:00:00 2001 From: Defool Date: Sat, 24 Dec 2022 22:04:19 +0800 Subject: [PATCH] Fix unexpected alter table in auto migration --- migrator/migrator.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/migrator/migrator.go b/migrator/migrator.go index eafe7bb29..376145998 100644 --- a/migrator/migrator.go +++ b/migrator/migrator.go @@ -445,7 +445,7 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy } } - if !isSameType { + if !isSameType && fullDataType != "mediumtext" && fullDataType != "longtext" { // check size if length, ok := columnType.Length(); length != int64(field.Size) { if length > 0 && field.Size > 0 { @@ -477,14 +477,6 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy } } - // check unique - if unique, ok := columnType.Unique(); ok && unique != field.Unique { - // not primary key - if !field.PrimaryKey { - alterColumn = true - } - } - // check default value if !field.PrimaryKey { currentDefaultNotNull := field.HasDefaultValue && !strings.EqualFold(field.DefaultValue, "NULL")