Skip to content

Commit 141388f

Browse files
authored
Fix AutoMigrate default value comparison for string fields (issue #7590) (#7591)
* feat:Capitalize the priority field of IndexOption so that other systems can access this field from outside the package. * bugfix:AutoMigrate #7590 * bugfix:defaultValue DefaultValue * feat:change to strings.Trim(field.DefaultValue, "'\"") for alterColumn
1 parent d9372f5 commit 141388f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

migrator/migrator.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,10 @@ func (m Migrator) MigrateColumn(value interface{}, field *schema.Field, columnTy
560560
v1, _ := strconv.ParseBool(dv)
561561
v2, _ := strconv.ParseBool(field.DefaultValue)
562562
alterColumn = v1 != v2
563+
case schema.String:
564+
if dv != field.DefaultValue && dv != strings.Trim(field.DefaultValue, "'\"") {
565+
alterColumn = true
566+
}
563567
default:
564568
alterColumn = dv != field.DefaultValue
565569
}

0 commit comments

Comments
 (0)