Skip to content

Commit

Permalink
Fix: pending_messages constraints (#681)
Browse files Browse the repository at this point in the history
* Fix: pending_messages constraint should have `sender` `item_hash` `signature`

* fix: unused import
  • Loading branch information
1yam authored Jan 14, 2025
1 parent 24409ed commit c0a0f51
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Fix: UniqueCOnstraint should have sender item_hash and signature
Revision ID: 46f7e55ff55c
Revises: edb195b0ed62
Create Date: 2025-01-14 17:51:43.357255
"""
from alembic import op


# revision identifiers, used by Alembic.
revision = '46f7e55ff55c'
down_revision = 'edb195b0ed62'
branch_labels = None
depends_on = None


def upgrade() -> None:
op.drop_constraint('uq_pending_message', 'pending_messages', type_='unique')
op.create_unique_constraint('uq_pending_message', 'pending_messages', ['sender', 'item_hash', 'signature'])


def downgrade() -> None:
op.drop_constraint('uq_pending_message', 'pending_messages', type_='unique')
op.create_unique_constraint('uq_pending_message', 'pending_messages', ['item_hash'])
2 changes: 1 addition & 1 deletion src/aleph/db/models/pending_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class PendingMessageDb(Base):
"signature is not null or not check_message",
name="signature_not_null_if_check_message",
),
UniqueConstraint("item_hash", name="uq_pending_message"),
UniqueConstraint("sender", "item_hash", "signature", name="uq_pending_message"),
)

tx: Optional[ChainTxDb] = relationship("ChainTxDb")
Expand Down

0 comments on commit c0a0f51

Please sign in to comment.