-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
base: dev
Are you sure you want to change the base?
Fix create/drop indexes in every migration #377
Conversation
c168d24
to
87207f7
Compare
…xes-in-every-migration
aerich/migrate.py
Outdated
ret.append(index) | ||
return ret | ||
def _eq(self, other) -> bool: | ||
return type(self) is type(other) and hash(self) == hash(other) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an incorrect implementation of __eq__
. Hashes happen to have collisions.
return type(self) is type(other) and hash(self) == hash(other) | ||
|
||
setattr(index_cls, "__hash__", _hash) | ||
setattr(index_cls, "__eq__", _eq) |
There was a problem hiding this comment.
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.
tests/models.py
Outdated
class Meta: | ||
indexes = [Index(fields=("is_active", "username"))] | ||
if "postgres" in os.getenv("TEST_DB", "") and len(indexes) == 1: | ||
indexes.append(HashIndex(fields=("intro",))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it required for postgres? Looks like a hack.
Base on #311
Will close #258