If we want to change column from varchar to int, it will report error like below:
[2022-05-09 11:57:51] INFO [db] /opt/homebrew/Cellar/go@1.17/1.17.9/pkg/mod/gorm.io/driver/postgres@v1.3.5/migrator.go:270 ERROR: column "xxx" cannot be cast automatically to type bigint (SQLSTATE 42804)
[1.840ms] [rows:0] ALTER TABLE "xxx" ALTER COLUMN "xxx" TYPE bigint
We only need to append USING xxx::bigint in func AlterColumn in postgres@v1.3.5/migrator.go
GORM Playground Link
https://github.com/go-gorm/playground/pull/475
Description
If we want to change column from varchar to int, it will report error like below: [2022-05-09 11:57:51] INFO [db] /opt/homebrew/Cellar/go@1.17/1.17.9/pkg/mod/gorm.io/driver/postgres@v1.3.5/migrator.go:270 ERROR: column "xxx" cannot be cast automatically to type bigint (SQLSTATE 42804) [1.840ms] [rows:0] ALTER TABLE "xxx" ALTER COLUMN "xxx" TYPE bigint
We only need to append USING xxx::bigint in func AlterColumn in postgres@v1.3.5/migrator.go