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

Can't AutoMigrate() tables with uniqueIndex since v1.25.6 on MySQL #6966

Closed
ov opened this issue Apr 15, 2024 · 2 comments
Closed

Can't AutoMigrate() tables with uniqueIndex since v1.25.6 on MySQL #6966

ov opened this issue Apr 15, 2024 · 2 comments
Assignees
Labels
type:with reproduction steps with reproduction steps

Comments

@ov
Copy link

ov commented Apr 15, 2024

GORM Playground Link

go-gorm/playground#717

Description

Starting with gorm 1.25.6 I can't automatically migrate tables with uniqueIndex constraint. Here's a very simple example with just one model and one field with the constraint. I removed DROP TABLE commands, so the database keeps the data between the test runs.

Now if you run the test the first time - it passes, if you run it again - you get the error:

Failed to auto migrate, but got error Error 1091 (42000): Can't DROP 'uni_entities_name'; check that column/key exists

This is tested with 1.25.9 and fails there. Works fine in 1.25.5, started failing in 1.25.6.

Tested with MySQL and fails there. Seems working OK with sqlite3 though...

@github-actions github-actions bot added the type:with reproduction steps with reproduction steps label Apr 15, 2024
@ov
Copy link
Author

ov commented Apr 15, 2024

I updated the test so it doesn't need to be run twice. I now call RunMigration() twice and it fails straight away.

@ov
Copy link
Author

ov commented Apr 15, 2024

My bad. After checking the CI logs from the pull request it looks like it works just fine on your side. I tested it further and it seems like upgrading gorm mysql driver 1.5.2->1.5.6 did the job.

Please ignore the issue. Thank you.

@ov ov closed this as completed Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:with reproduction steps with reproduction steps
Projects
None yet
Development

No branches or pull requests

2 participants