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

#5635 Add Config.DryRunMigration to prevent actually changing the schema when doing AutoMigrate() #5639

Closed
wants to merge 1 commit into from

Conversation

googollee
Copy link
Contributor

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

Add a flag Config.DryRunMigration to let AutoMigrate() return an error before changing the schema.

User Case Description

See #5635.

@googollee
Copy link
Contributor Author

postgres tests failed.

2022/08/24 15:36:20 /home/runner/go/pkg/mod/gorm.io/driver/postgres@v1.3.9/migrator.go:140 ERROR: multiple default values specified for column "id" of table "posts" (SQLSTATE 42601)
[0.316ms] [rows:0] CREATE TABLE "posts" ("id" smallserial DEFAULT uuid_generate_v4(),"title" text,PRIMARY KEY ("id"))

2022/08/24 15:36:20 /home/runner/work/gorm/gorm/tests/postgres_test.go:97 ERROR: relation "posts" does not exist (SQLSTATE 42P01)
[0.662ms] [rows:0] INSERT INTO "posts" ("title") VALUES ('Hello World') RETURNING "id"
--- FAIL: TestMany2ManyWithDefaultValueUUID (0.01s)
    postgres_test.go:98: Failed, got error: ERROR: relation "posts" does not exist (SQLSTATE 42P01)

I don't think I touched that part.

@googollee
Copy link
Contributor Author

That failure should be fixed by #5620.

@googollee
Copy link
Contributor Author

This pr doesn't work properly. Closed.

@googollee googollee closed this Aug 25, 2022
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.

None yet

1 participant