GORM Playground Link
https://github.com/go-gorm/playground/pull/526
Description
Defining a model with default:CURRENT_TIMESTAMP:
type TimestampTest struct {
TimeAt *time.Time `gorm:"type:datetime;not null;default:CURRENT_TIMESTAMP"`
}
... and then executing AutoMigrate(&TimestampTest) causes ALTER TABLE to execute on every invocation, not just the first time.
This is reproducible with sqlite, mysql, and postgres:
GORM_DIALECT=sqlite GORM_ENABLE_CACHE=true ./test.sh
GORM_DIALECT=mysql GORM_ENABLE_CACHE=true ./test.sh
GORM_DIALECT=postgres GORM_ENABLE_CACHE=true ./test.sh