Add unique constraint hash received offer (#732)

* Add unique constraint on payment hash in received offers table

* Fix unique constraint
This commit is contained in:
Jonathan Zernik 2021-01-27 18:07:19 -08:00 committed by GitHub
parent 26beeda41e
commit 43480865fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 1 deletions

View file

@ -0,0 +1,33 @@
"""Add unique constraint on payment hash of received offer
Revision ID: cd3f18ee33c8
Revises: df59995f322c
Create Date: 2021-01-27 17:40:06.995928
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = 'cd3f18ee33c8'
down_revision = 'df59995f322c'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('received_offer', schema=None) as batch_op:
batch_op.create_unique_constraint(
'uq_received_offer_payment_hash', ['payment_hash'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('received_offer', schema=None) as batch_op:
batch_op.drop_constraint(
'uq_received_offer_payment_hash', type_='unique')
# ### end Alembic commands ###

View file

@ -87,7 +87,7 @@ class Models:
Column("created", TZDateTime,
server_default=func.now(), nullable=False),
Column("squeak_hash", String(64), nullable=False),
Column("payment_hash", String(64), nullable=False),
Column("payment_hash", String(64), unique=True, nullable=False),
Column("nonce", String(64), nullable=False),
Column("payment_point", String(66), nullable=False),
Column("invoice_timestamp", Integer, nullable=False),