GORM Playground Link

https://github.com/go-gorm/playground/pull/644

Description

Every time we run AutoMigrage we get the same

ALTER TABLE "X"."Y" ALTER COLUMN "Z" SET DEFAULT '';;

Even thought the column definition is already correct. We currently cannot ignore this as we generate migration files for every PR that changes the schema. Also no known workaround.

Comment From: moolitayer

@jinzhu PTAL at this issue with a reproduction. Also, not sure if that's the issue, but on debugging I noticed in (migrator/migrator.go)[https://github.com/go-gorm/gorm/blob/master/migrator/migrator.go#L439C25-L439C25] that the default from the DB is read as ''::TEXT

Comment From: moolitayer

Thanks @jinzhu! much appreciated.

Comment From: artlo

Doesn't it loose the default value?

I've also found this issue but in case of model generation. If the text field has the empty string as default value it generates model with following tag: default:"''::text", so the table column will have the value ::text. I tried to fix it with the following line: column.DefaultValueValue.String = regexp.MustCompile('?(.*\b|)'?:+[\w\s]+$).ReplaceAllString(column.DefaultValueValue.String, "$1")