Skip to content

Commit 18727db

Browse files
committed
Add block_index to transaction
1 parent d5cfbf9 commit 18727db

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""Add block_index to transaction
2+
3+
Revision ID: c138389e735b
4+
Revises: 321b2954fdf2
5+
Create Date: 2025-10-18 18:39:32.549559
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
import sqlalchemy as sa
12+
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = 'c138389e735b'
16+
down_revision: Union[str, None] = '321b2954fdf2'
17+
branch_labels: Union[str, Sequence[str], None] = None
18+
depends_on: Union[str, Sequence[str], None] = None
19+
20+
21+
def upgrade() -> None:
22+
# ### commands auto generated by Alembic - please adjust! ###
23+
op.add_column('service_transactions', sa.Column('block_index', sa.Integer(), nullable=True))
24+
# ### end Alembic commands ###
25+
26+
27+
def downgrade() -> None:
28+
# ### commands auto generated by Alembic - please adjust! ###
29+
op.drop_column('service_transactions', 'block_index')
30+
# ### end Alembic commands ###

app/models/transaction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ class Transaction(Base):
3131
amount: Mapped[dict[str, float]] = mapped_column(JSONB, default={})
3232

3333
coinbase: Mapped[bool] = mapped_column(nullable=True)
34+
block_index: Mapped[int] = mapped_column(nullable=True)

app/sync/chain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ async def process_block(session: AsyncSession, data: dict[str, Any]):
7373
"txid": transaction_data["txid"],
7474
"currencies": transaction_currencies[transaction_data["txid"]],
7575
"coinbase": transaction_data["coinbase"],
76+
"block_index": transaction_data["index"],
7677
"height": block.height,
7778
"amount": {
7879
currency: float(amount)

0 commit comments

Comments
 (0)