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

AutoMigrate recreates table with composite unique index even if the m… #660

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

Conversation

tyr0chen
Copy link

@tyr0chen tyr0chen commented Nov 11, 2023

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.

…odel has not changed

Signed-off-by: tyrchen <tyrchen@tencent.com>
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