Skip to content

If a field in a database table uses the serializer tag and AutoMigrate is used, then even if there are no changes to this field, AutoMigrate will still perform an ALTER on the table every time #7590

@nowindexman

Description

@nowindexman

GORM Playground Link

go-gorm/playground#830

Description

Image

If a field in a database table uses the serializer tag and AutoMigrate is used, then even if there are no changes to this field,AutoMigrate will still perform an ALTER on the table every time.

Image

The reason is that during the AutoMigrate comparison, the default value read from the database does not match the default value bound by GORM. The dv variable is read from the database, while field.DefaultValue is obtained by GORM after reading the struct. field.DefaultValue includes an extra layer of single quotes (''), causing the values to not match.

Others have also encountered this issue. #7553

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions