go-gorm / playground

GORM Playground (Please Create PR for this project to report issues)
MIT License
90 stars 688 forks source link

Add reproduction for equivalent types remigration #646

Open moolitayer opened 1 year ago

moolitayer commented 1 year ago

Explain your user case and expected results

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:

to

Also effects other types: