tortoise / aerich

A database migrations tool for TortoiseORM, ready to production.
https://github.com/tortoise/aerich
Apache License 2.0
804 stars 90 forks source link

Add `__eq__` method for `Index` instances #311

Open fullonic opened 11 months ago

fullonic commented 11 months ago

Fix https://github.com/tortoise/aerich/issues/258

This issue happens because new_indexes.difference(old_indexes) [code] and old_indexes.difference(new_indexes) [code] returns always all indexes, even when they are equal.

This PR fixes this by adding the __eq__ to all Index instances. To ensure that indexes are equal we compare them using the __hash__ method.