Token indexes

This commit is contained in:
tim
2024-10-05 15:26:14 -04:00
parent c60bc219f6
commit c912cbfb25
2 changed files with 34 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
import logging
from typing import TypedDict, Optional, NotRequired
from sqlalchemy import Index
from sqlalchemy.orm import Mapped, mapped_column
from dexorder.database.column import Address, Blockchain, Uint8
@@ -39,10 +40,14 @@ class Token (Base):
chain: Mapped[Blockchain] = mapped_column(primary_key=True)
address: Mapped[Address] = mapped_column(primary_key=True)
name: Mapped[str]
symbol: Mapped[str]
symbol: Mapped[str] = mapped_column(index=True)
decimals: Mapped[Uint8]
approved: Mapped[bool] = mapped_column(index=True)
__table_args__ = (
Index('idx_name', 'name', postgresql_using='gist'), # full text search on name
)
@staticmethod
def load(token_dict: OldTokenDict) -> 'Token':