AutoMigrate recreates table with composite unique index even if the m… #660
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explain your user case and expected results
In my use case, in sqlite driver, I have a model Gateway with a composite unique index defined on the fields IP and UIN. I expect that when running AutoMigrate, the table should only be recreated if there are changes to the model structure. However, I observed that the table is recreated every time AutoMigrate is called, even when the model has not changed.
Expected results:
When using a composite unique index, the table should not be recreated during AutoMigrate if the model structure has not changed.
The unique attribute should be properly set for fields within a composite unique index, without affecting the behavior of AutoMigrate.
After modifying the condition in the sqlite-driver code as mentioned in the original issue description, the behavior is as expected and the table is not recreated during AutoMigrate when the model has not changed.