Gorm tries to migrate between equivalent types.
In this example, type:character varying will get remigrated everytime (to type:varchar).
GORM_DIALECT=postgres ./test.sh| grep ALTER
Cloning into 'gorm'...
remote: Enumerating objects: 179, done.
remote: Counting objects: 100% (179/179), done.
remote: Compressing objects: 100% (173/173), done.
remote: Total 179 (delta 11), reused 59 (delta 4), pack-reused 0
Receiving objects: 100% (179/179), 224.23 KiB | 1.25 MiB/s, done.
Resolving deltas: 100% (11/11), done.
playground_postgres_1 is up-to-date
playground_mysql_1 is up-to-date
playground_mssql_1 is up-to-date
package github.com/microsoft/go-sqlcmd/cmd/sqlcmd is not a main package
[3.368ms] [rows:0] ALTER TABLE "toys" ALTER COLUMN "migrated" TYPE character varying USING "migrated"::character varying
[1.278ms] [rows:0] ALTER TABLE "toys" ALTER COLUMN "migrated" TYPE character varying USING "migrated"::character varying
I'm not sure how it worked in the past but,
This started happening on upgrade from:
gorm.io/driver/postgres v1.2.3
gorm.io/gorm v1.22.5
to
gorm.io/driver/postgres v1.5.2
gorm.io/gorm v1.25.2
Also effects other types:
Forces timestamptz over timestamp with time zone
Forces character varying[] over varchar[]
Forces default:false over default:FALSE
Forces default:ARRAY[]::bigint[] over default:array[]::bigint[]
Forces default:ARRAY[]::character varying[] over default:array[]::character varying[]
Explain your user case and expected results
Gorm tries to migrate between equivalent types. In this example,
type:character varying
will get remigrated everytime (totype:varchar
).I'm not sure how it worked in the past but,
This started happening on upgrade from:
to
Also effects other types:
timestamptz
overtimestamp with time zone
character varying[]
overvarchar[]
default:false
overdefault:FALSE
default:ARRAY[]::bigint[]
overdefault:array[]::bigint[]
default:ARRAY[]::character varying[]
overdefault:array[]::character varying[]