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

Fix create/drop indexes in every migration #377

Merged

Conversation

waketzheng
Copy link
Contributor

Base on #311

Will close #258

@waketzheng waketzheng requested a review from henadzit December 6, 2024 11:11
aerich/migrate.py Outdated Show resolved Hide resolved
@waketzheng waketzheng force-pushed the fix/create-drop-indexes-in-every-migration branch from c168d24 to 87207f7 Compare December 7, 2024 02:18
@waketzheng
Copy link
Contributor Author

@henadzit Cloud you review it and #376 again?

aerich/migrate.py Outdated Show resolved Hide resolved
return type(self) is type(other) and hash(self) == hash(other)

setattr(index_cls, "__hash__", _hash)
setattr(index_cls, "__eq__", _eq)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are setting the lower boundary on the tortoise version in #388. Why not just implement __eq__ and __hash__ in Tortoise and set the corresponding version boundary. You won't have to have this hacky code then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@henadzit I check the tortoise version before patch Index and add a TODO mark.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, can you please let me know your arguments for why you want to have the patching code instead of increasing the version requirements?

tests/models.py Outdated Show resolved Hide resolved
aerich/migrate.py Show resolved Hide resolved
return type(self) is type(other) and hash(self) == hash(other)

setattr(index_cls, "__hash__", _hash)
setattr(index_cls, "__eq__", _eq)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, can you please let me know your arguments for why you want to have the patching code instead of increasing the version requirements?

Copy link
Contributor

@henadzit henadzit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@waketzheng waketzheng merged commit 7d22518 into tortoise:dev Dec 21, 2024
18 checks passed
@waketzheng waketzheng deleted the fix/create-drop-indexes-in-every-migration branch December 22, 2024 12:28
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.

New migration file on migrate for Indexes defined on a Model.
3 participants