Fix AutoMigrate, alterColumn The previous modifications were ignored

This commit is contained in:
LIN 2025-02-13 13:32:40 +08:00
parent 9ca84b3dde
commit 68e45f1c2c

View File

@ -531,7 +531,7 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy
}
// check default value
if !field.PrimaryKey {
if !alterColumn && !field.PrimaryKey {
currentDefaultNotNull := field.HasDefaultValue && (field.DefaultValueInterface != nil || !strings.EqualFold(field.DefaultValue, "NULL"))
dv, dvNotNull := columnType.DefaultValue()
if dvNotNull && !currentDefaultNotNull {