Added EthereumSmartContract model to database

pull/27/head
Neeraj Kashyap 2021-07-28 20:58:56 -07:00
rodzic c5422c920d
commit a046d33804
3 zmienionych plików z 71 dodań i 3 usunięć

Wyświetl plik

@ -0,0 +1,52 @@
"""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 = "1e33c3d07306"
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

@ -1,3 +1,4 @@
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import (
BigInteger,
@ -102,6 +103,12 @@ class EthereumTransaction(Base): # type: ignore
DateTime(timezone=True), server_default=utcnow(), nullable=False
)
class EthereumSmartContract(Base): # type: ignore
__tablename__ = "ethereum_smart_contracts"
id = Column(Integer, primary_key=True)
transaction_hash = Column(VARCHAR(256), ForeignKey("ethereum_transactions.hash", ondelete="CASCADE"), nullable=False)
address = Column(VARCHAR(256), nullable=False, index=True)
class EthereumPendingTransaction(Base): # type: ignore
__tablename__ = "ethereum_pending_transactions"
@ -130,8 +137,7 @@ class EthereumPendingTransaction(Base): # type: ignore
DateTime(timezone=True), server_default=utcnow(), nullable=False
)
class ESDFunctionSignature(Base):
class ESDFunctionSignature(Base): # type: ignore
"""
Function signature from Ethereum Signature Database.
"""
@ -146,7 +152,7 @@ class ESDFunctionSignature(Base):
)
class ESDEventSignature(Base):
class ESDEventSignature(Base): # type: ignore
"""
Function signature from Ethereum Signature Database.
"""

10
db/mypy.ini 100644
Wyświetl plik

@ -0,0 +1,10 @@
[mypy]
[mypy-sqlalchemy.*]
ignore_missing_imports = True
[mypy-moonstreamdb.*]
ignore_missing_imports = True
[mypy-pyevmasm.*]
ignore_missing_imports = True