go-gorm / playground

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

can't migrate tables with uniqueIndex #717

Closed ov closed 3 months ago

ov commented 3 months ago

Explain your user case and expected results

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...