kopia lustrzana https://github.com/bugout-dev/moonstream
Created additional indices
rodzic
9e6fa856bb
commit
f3cb5e53ab
|
@ -0,0 +1,46 @@
|
|||
"""Additional indices
|
||||
|
||||
Revision ID: 2d967953f847
|
||||
Revises: 1e33c3d07306
|
||||
Create Date: 2021-07-29 14:27:44.624965
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2d967953f847'
|
||||
down_revision = '1e33c3d07306'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_index(op.f('ix_esd_event_signatures_id'), 'esd_event_signatures', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_esd_function_signatures_id'), 'esd_function_signatures', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_ethereum_blocks_hash'), 'ethereum_blocks', ['hash'], unique=False)
|
||||
op.create_unique_constraint(op.f('uq_ethereum_blocks_block_number'), 'ethereum_blocks', ['block_number'])
|
||||
op.create_index(op.f('ix_ethereum_pending_transactions_block_number'), 'ethereum_pending_transactions', ['block_number'], unique=False)
|
||||
op.create_index(op.f('ix_ethereum_pending_transactions_hash'), 'ethereum_pending_transactions', ['hash'], unique=True)
|
||||
op.create_index(op.f('ix_ethereum_pending_transactions_value'), 'ethereum_pending_transactions', ['value'], unique=False)
|
||||
op.create_index(op.f('ix_ethereum_transactions_block_number'), 'ethereum_transactions', ['block_number'], unique=False)
|
||||
op.create_index(op.f('ix_ethereum_transactions_hash'), 'ethereum_transactions', ['hash'], unique=True)
|
||||
op.create_index(op.f('ix_ethereum_transactions_value'), 'ethereum_transactions', ['value'], unique=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_index(op.f('ix_ethereum_transactions_value'), table_name='ethereum_transactions')
|
||||
op.drop_index(op.f('ix_ethereum_transactions_hash'), table_name='ethereum_transactions')
|
||||
op.drop_index(op.f('ix_ethereum_transactions_block_number'), table_name='ethereum_transactions')
|
||||
op.drop_index(op.f('ix_ethereum_pending_transactions_value'), table_name='ethereum_pending_transactions')
|
||||
op.drop_index(op.f('ix_ethereum_pending_transactions_hash'), table_name='ethereum_pending_transactions')
|
||||
op.drop_index(op.f('ix_ethereum_pending_transactions_block_number'), table_name='ethereum_pending_transactions')
|
||||
op.drop_constraint(op.f('uq_ethereum_blocks_block_number'), 'ethereum_blocks', type_='unique')
|
||||
op.drop_index(op.f('ix_ethereum_blocks_hash'), table_name='ethereum_blocks')
|
||||
op.drop_index(op.f('ix_esd_function_signatures_id'), table_name='esd_function_signatures')
|
||||
op.drop_index(op.f('ix_esd_event_signatures_id'), table_name='esd_event_signatures')
|
||||
# ### end Alembic commands ###
|
|
@ -58,7 +58,7 @@ class EthereumBlock(Base): # type: ignore
|
|||
extra_data = Column(VARCHAR(128))
|
||||
gas_limit = Column(BigInteger)
|
||||
gas_used = Column(BigInteger)
|
||||
hash = Column(VARCHAR(256))
|
||||
hash = Column(VARCHAR(256), index=True)
|
||||
logs_bloom = Column(VARCHAR(1024))
|
||||
miner = Column(VARCHAR(256))
|
||||
nonce = Column(VARCHAR(256))
|
||||
|
@ -79,15 +79,13 @@ class EthereumTransaction(Base): # type: ignore
|
|||
__tablename__ = "ethereum_transactions"
|
||||
|
||||
hash = Column(
|
||||
VARCHAR(256),
|
||||
primary_key=True,
|
||||
unique=True,
|
||||
nullable=False,
|
||||
VARCHAR(256), primary_key=True, unique=True, nullable=False, index=True
|
||||
)
|
||||
block_number = Column(
|
||||
BigInteger,
|
||||
ForeignKey("ethereum_blocks.block_number", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
from_address = Column(VARCHAR(256), index=True)
|
||||
to_address = Column(VARCHAR(256), index=True)
|
||||
|
@ -96,7 +94,7 @@ class EthereumTransaction(Base): # type: ignore
|
|||
input = Column(Text)
|
||||
nonce = Column(VARCHAR(256))
|
||||
transaction_index = Column(BigInteger)
|
||||
value = Column(Text)
|
||||
value = Column(Text, index=True)
|
||||
|
||||
indexed_at = Column(
|
||||
DateTime(timezone=True), server_default=utcnow(), nullable=False
|
||||
|
@ -107,15 +105,13 @@ class EthereumPendingTransaction(Base): # type: ignore
|
|||
__tablename__ = "ethereum_pending_transactions"
|
||||
|
||||
hash = Column(
|
||||
VARCHAR(256),
|
||||
primary_key=True,
|
||||
unique=True,
|
||||
nullable=False,
|
||||
VARCHAR(256), primary_key=True, unique=True, nullable=False, index=True
|
||||
)
|
||||
block_number = Column(
|
||||
BigInteger,
|
||||
ForeignKey("ethereum_blocks.block_number", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
index=True,
|
||||
)
|
||||
from_address = Column(VARCHAR(256), index=True)
|
||||
to_address = Column(VARCHAR(256), index=True)
|
||||
|
@ -124,7 +120,7 @@ class EthereumPendingTransaction(Base): # type: ignore
|
|||
input = Column(Text)
|
||||
nonce = Column(VARCHAR(256))
|
||||
transaction_index = Column(BigInteger)
|
||||
value = Column(Text)
|
||||
value = Column(Text, index=True)
|
||||
|
||||
indexed_at = Column(
|
||||
DateTime(timezone=True), server_default=utcnow(), nullable=False
|
||||
|
@ -138,7 +134,7 @@ class ESDFunctionSignature(Base):
|
|||
|
||||
__tablename__ = "esd_function_signatures"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
text_signature = Column(Text, nullable=False)
|
||||
hex_signature = Column(VARCHAR(10), nullable=False)
|
||||
created_at = Column(
|
||||
|
@ -153,7 +149,7 @@ class ESDEventSignature(Base):
|
|||
|
||||
__tablename__ = "esd_event_signatures"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
text_signature = Column(Text, nullable=False)
|
||||
hex_signature = Column(VARCHAR(66), nullable=False)
|
||||
created_at = Column(
|
||||
|
|
Ładowanie…
Reference in New Issue