Added indexing to smart contract transaction hashes

Consolidated into a single alembic revision
pull/27/head
Neeraj Kashyap 2021-07-30 09:02:08 -07:00
rodzic 3e207b1226
commit 472aeae1e3
3 zmienionych plików z 39 dodań i 52 usunięć

Wyświetl plik

@ -0,0 +1,38 @@
"""Ethereum smart contracts
Revision ID: 571f33ad7587
Revises: 21cced47077c
Create Date: 2021-07-30 09:00:18.945935
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '571f33ad7587'
down_revision = '21cced47077c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('ethereum_smart_contracts',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('transaction_hash', sa.VARCHAR(length=256), nullable=False),
sa.Column('address', sa.VARCHAR(length=256), nullable=False),
sa.ForeignKeyConstraint(['transaction_hash'], ['ethereum_transactions.hash'], name=op.f('fk_ethereum_smart_contracts_transaction_hash_ethereum_transactions'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id', name=op.f('pk_ethereum_smart_contracts'))
)
op.create_index(op.f('ix_ethereum_smart_contracts_address'), 'ethereum_smart_contracts', ['address'], unique=False)
op.create_index(op.f('ix_ethereum_smart_contracts_transaction_hash'), 'ethereum_smart_contracts', ['transaction_hash'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_ethereum_smart_contracts_transaction_hash'), table_name='ethereum_smart_contracts')
op.drop_index(op.f('ix_ethereum_smart_contracts_address'), table_name='ethereum_smart_contracts')
op.drop_table('ethereum_smart_contracts')
# ### end Alembic commands ###

Wyświetl plik

@ -1,52 +0,0 @@
"""ethereum_smart_contracts
Revision ID: b6842e6c720d
Revises: 1e33c3d07306
Create Date: 2021-07-28 20:57:07.739567
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "b6842e6c720d"
down_revision = "21cced47077c"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"ethereum_smart_contracts",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("transaction_hash", sa.VARCHAR(length=256), nullable=False),
sa.Column("address", sa.VARCHAR(length=256), nullable=False),
sa.ForeignKeyConstraint(
["transaction_hash"],
["ethereum_transactions.hash"],
name=op.f(
"fk_ethereum_smart_contracts_transaction_hash_ethereum_transactions"
),
ondelete="CASCADE",
),
sa.PrimaryKeyConstraint("id", name=op.f("pk_ethereum_smart_contracts")),
)
op.create_index(
op.f("ix_ethereum_smart_contracts_address"),
"ethereum_smart_contracts",
["address"],
unique=False,
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(
op.f("ix_ethereum_smart_contracts_address"),
table_name="ethereum_smart_contracts",
)
op.drop_table("ethereum_smart_contracts")
# ### end Alembic commands ###

Wyświetl plik

@ -108,6 +108,7 @@ class EthereumSmartContract(Base): # type: ignore
VARCHAR(256),
ForeignKey("ethereum_transactions.hash", ondelete="CASCADE"),
nullable=False,
index=True,
)
address = Column(VARCHAR(256), nullable=False, index=True)