Token indexes
This commit is contained in:
28
alembic/versions/86afa7b6415d_token_indexes.py
Normal file
28
alembic/versions/86afa7b6415d_token_indexes.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""token indexes
|
||||
|
||||
Revision ID: 86afa7b6415d
|
||||
Revises: 516b55c83144
|
||||
Create Date: 2024-10-05 15:19:05.023706
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '86afa7b6415d'
|
||||
down_revision: Union[str, None] = '516b55c83144'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_index(op.f('ix_token_name'), 'token', ['name'], unique=False, postgresql_using='gist')
|
||||
op.create_index(op.f('ix_token_approved'), 'token', ['approved'], unique=False)
|
||||
op.create_index(op.f('ix_token_symbol'), 'token', ['symbol'], unique=False)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index(op.f('ix_token_symbol'), table_name='token')
|
||||
op.drop_index(op.f('ix_token_approved'), table_name='token')
|
||||
op.drop_index(op.f('ix_token_name'), table_name='token', postgresql_using='gist')
|
||||
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user