Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add issue reproduction of contant recreation #644

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

moolitayer
Copy link

@moolitayer moolitayer commented Aug 23, 2023

Explain your user case and expected results

When we have a gorm object with a varchar colum and a '' default value, gorm constantly tries to alter the table, even though the default value is already set currectly. This causes an issue we cannot avoid since we write our migrations to migrations files and not automatically execute them. We use a Postgre DB.

You can see this by typing

$ 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% (172/172), done.
remote: Total 179 (delta 11), reused 62 (delta 5), pack-reused 0
Receiving objects: 100% (179/179), 222.93 KiB | 1.16 MiB/s, done.
Resolving deltas: 100% (11/11), done.
playground_mssql_1 is up-to-date
playground_mysql_1 is up-to-date
playground_postgres_1 is up-to-date
package github.com/microsoft/go-sqlcmd/cmd/sqlcmd is not a main package
[2.034ms] [rows:0] ALTER TABLE "toys" ALTER COLUMN "name" SET DEFAULT ''
[1.616ms] [rows:0] ALTER TABLE "toys" ALTER COLUMN "name" SET DEFAULT ''
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant