mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-16 13:01:04 +02:00
Add composite contraint of squeak hash and client addr in sent offers table (#736)
This commit is contained in:
parent
2cab41edff
commit
e59a68b0a4
2 changed files with 36 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
"""Add composite unique constraint on squeak hash and client addr of sent offer
|
||||
|
||||
Revision ID: d5a06570ed3e
|
||||
Revises: cd3f18ee33c8
|
||||
Create Date: 2021-01-28 17:49:17.615748
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd5a06570ed3e'
|
||||
down_revision = 'cd3f18ee33c8'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sent_offer', schema=None) as batch_op:
|
||||
batch_op.create_unique_constraint('uq_sent_offer_squeak_hash_client_addr', [
|
||||
'squeak_hash', 'client_addr'])
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('sent_offer', schema=None) as batch_op:
|
||||
batch_op.drop_constraint(
|
||||
'uq_sent_offer_squeak_hash_client_addr', type_='unique')
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
|
@ -10,6 +10,7 @@ from sqlalchemy import Integer
|
|||
from sqlalchemy import MetaData
|
||||
from sqlalchemy import String
|
||||
from sqlalchemy import Table
|
||||
from sqlalchemy import UniqueConstraint
|
||||
from sqlalchemy.types import TypeDecorator
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -130,6 +131,8 @@ class Models:
|
|||
Column("invoice_timestamp", Integer, nullable=False),
|
||||
Column("invoice_expiry", Integer, nullable=False),
|
||||
Column("client_addr", String(64), nullable=False),
|
||||
UniqueConstraint('squeak_hash', 'client_addr',
|
||||
name='uq_sent_offer_squeak_hash_client_addr')
|
||||
)
|
||||
|
||||
self.received_payments = Table(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue