Fix auto migrate field with customized field type, close https://github.com/go-gorm/mysql/issues/20

This commit is contained in:
Jinzhu 2020-12-23 17:31:47 +08:00
parent 77bf4aecc6
commit 59730417aa
1 changed files with 1 additions and 1 deletions

View File

@ -381,7 +381,7 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy
// check precision
if precision, _, ok := columnType.DecimalSize(); ok && int64(field.Precision) != precision {
if strings.Contains(m.DataTypeOf(field), fmt.Sprint(field.Precision)) {
if regexp.MustCompile(fmt.Sprintf("[^0-9]%d[^0-9]", field.Precision)).MatchString(m.DataTypeOf(field)) {
alterColumn = true
}
}