Fix create/drop indexes in every migration (#377)

* Add `__eq__` method for `Index`instances

* tests: add Index test case

* refactor: compare index instances before set hash and eq func to class

* fix: sort fields when generating index hash

* docs: update changlog

* fix style issue

* refactor: use CustomIndex instead of postgres special HashIndex

* Check tortoise version before patch Index

* Add comment

* Add comment for why > work

---------

Co-authored-by: dbf <somnium@riseup.net>
This commit is contained in:
Waket Zheng
2024-12-22 00:24:18 +08:00
committed by GitHub
parent f93faa8afb
commit 7d22518c74
6 changed files with 44 additions and 15 deletions

7
tests/indexes.py Normal file
View File

@@ -0,0 +1,7 @@
from tortoise.indexes import Index
class CustomIndex(Index):
def __init__(self, *args, **kw) -> None:
super().__init__(*args, **kw)
self._foo = ""