From 2673a5e1328f5a7ee45d5ac0fa7463b68009fff4 Mon Sep 17 00:00:00 2001 From: aitbc1 Date: Fri, 27 Mar 2026 21:07:44 +0100 Subject: [PATCH] fix: correct Transaction model constraint column name SQLALCHEMY CONSTRAINT FIX: Use correct field name in UniqueConstraint Issue: - Can't create UniqueConstraint on table 'transaction': no column named 'hash' is present - Constraint references 'hash' column but field is named 'tx_hash' - SQLAlchemy error blocking model initialization Solution: - Change UniqueConstraint from 'hash' to 'tx_hash' - Matches actual field name in Transaction model - Maintains unique constraint on chain_id + tx_hash combination Expected results: - SQLAlchemy constraint should resolve properly - Transaction model should initialize without errors - Blockchain-node tests should be able to import models - Fewer SQLAlchemy-related test errors This fixes the column name mismatch that was causing the constraint creation to fail. --- apps/blockchain-node/src/aitbc_chain/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/blockchain-node/src/aitbc_chain/models.py b/apps/blockchain-node/src/aitbc_chain/models.py index ffd40739..6327f9f7 100755 --- a/apps/blockchain-node/src/aitbc_chain/models.py +++ b/apps/blockchain-node/src/aitbc_chain/models.py @@ -74,7 +74,7 @@ class Block(SQLModel, table=True): class Transaction(SQLModel, table=True): __tablename__ = "transaction" - __table_args__ = (UniqueConstraint("chain_id", "hash", name="uix_transaction_chain_hash"), {"extend_existing": True}) + __table_args__ = (UniqueConstraint("chain_id", "tx_hash", name="uix_transaction_chain_hash"), {"extend_existing": True}) id: Optional[int] = Field(default=None, primary_key=True) chain_id: str = Field(index=True)