Adds foreign key constraint to ethereum_labels.transaction_hash

This is something we forgot to do in the previous migration.
pull/226/head
Neeraj Kashyap 2021-09-02 23:02:02 -07:00
rodzic ad94507553
commit b9a48b464e
2 zmienionych plików z 19 dodań i 7 usunięć

Wyświetl plik

@ -1,8 +1,8 @@
"""Support labels on transactions
Revision ID: 39a5bb9cffcf
Revision ID: 72f1ad512b2e
Revises: ecb7817db377
Create Date: 2021-09-02 22:54:39.055168
Create Date: 2021-09-02 22:59:46.408595
"""
from alembic import op
@ -10,7 +10,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "39a5bb9cffcf"
revision = "72f1ad512b2e"
down_revision = "ecb7817db377"
branch_labels = None
depends_on = None
@ -31,8 +31,13 @@ def upgrade():
["transaction_hash"],
unique=False,
)
op.create_unique_constraint(
op.f("uq_opensea_crawler_state_id"), "opensea_crawler_state", ["id"]
op.create_foreign_key(
op.f("fk_ethereum_labels_transaction_hash_ethereum_transactions"),
"ethereum_labels",
"ethereum_transactions",
["transaction_hash"],
["hash"],
ondelete="CASCADE",
)
# ### end Alembic commands ###
@ -40,7 +45,9 @@ def upgrade():
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(
op.f("uq_opensea_crawler_state_id"), "opensea_crawler_state", type_="unique"
op.f("fk_ethereum_labels_transaction_hash_ethereum_transactions"),
"ethereum_labels",
type_="foreignkey",
)
op.drop_index(
op.f("ix_ethereum_labels_transaction_hash"), table_name="ethereum_labels"

Wyświetl plik

@ -150,7 +150,12 @@ class EthereumLabel(Base): # type: ignore
nullable=True,
index=True,
)
transaction_hash = Column(VARCHAR(256), nullable=True, index=True)
transaction_hash = Column(
VARCHAR(256),
ForeignKey("ethereum_transactions.hash", ondelete="CASCADE"),
nullable=True,
index=True,
)
label_data = Column(JSONB, nullable=True)
created_at = Column(
DateTime(timezone=True), server_default=utcnow(), nullable=False