From 6c19f3ac0fbb8825081ea1ea37ebe5799e99696c Mon Sep 17 00:00:00 2001 From: jm Date: Thu, 12 Dec 2024 16:08:23 +0400 Subject: [PATCH] fix: For time type, the time field will be automatically updated. Even if the table structure is not changed, the table modification operation will be repeated. --- migrator/migrator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrator/migrator.go b/migrator/migrator.go index cec4e30f..b78baf01 100644 --- a/migrator/migrator.go +++ b/migrator/migrator.go @@ -543,7 +543,7 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy } else if currentDefaultNotNull || dvNotNull { switch field.GORMDataType { case schema.Time: - if !strings.EqualFold(strings.TrimSuffix(dv, "()"), strings.TrimSuffix(field.DefaultValue, "()")) { + if !strings.EqualFold(strings.Split(dv, "(")[0], strings.Split(field.DefaultValue, "(")[0]) { alterColumn = true } case schema.Bool: