tx_hash for call_requests field

pull/932/head
kompotkot 2023-10-04 11:27:40 +00:00
rodzic 47b76ec26d
commit 69e375ab61
4 zmienionych plików z 33 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,30 @@
"""Tx hash for call requests
Revision ID: 7191eb70e99e
Revises: 4f05d212ea49
Create Date: 2023-10-04 11:23:12.516797
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '7191eb70e99e'
down_revision = '4f05d212ea49'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('call_requests', sa.Column('tx_hash', sa.VARCHAR(length=256), nullable=True))
op.create_unique_constraint(op.f('uq_call_requests_tx_hash'), 'call_requests', ['tx_hash'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(op.f('uq_call_requests_tx_hash'), 'call_requests', type_='unique')
op.drop_column('call_requests', 'tx_hash')
# ### end Alembic commands ###

Wyświetl plik

@ -100,6 +100,7 @@ def parse_call_request_response(
method=obj[0].method,
request_id=str(obj[0].request_id),
parameters=obj[0].parameters,
tx_hash=obj[0].tx_hash,
expires_at=obj[0].expires_at,
live_at=obj[0].live_at,
created_at=obj[0].created_at,

Wyświetl plik

@ -306,6 +306,7 @@ class CallRequestResponse(BaseModel):
method: str
request_id: str
parameters: Dict[str, Any]
tx_hash: Optional[str] = None
expires_at: Optional[datetime] = None
live_at: datetime
created_at: datetime

Wyświetl plik

@ -313,6 +313,7 @@ class CallRequest(Base):
method = Column(String, nullable=False, index=True)
request_id = Column(DECIMAL, nullable=False, index=True)
parameters = Column(JSONB, nullable=False)
tx_hash = Column(VARCHAR(256), unique=True, nullable=True)
expires_at = Column(DateTime(timezone=True), nullable=True, index=True)
live_at = Column(DateTime(timezone=True), server_default=utcnow(), nullable=False)