Unique const for addr in ethereum_address table

pull/115/head
kompotkot 2021-08-18 09:46:34 +00:00
rodzic 6d3e2cf913
commit 776d00fb0d
2 zmienionych plików z 33 dodań i 1 usunięć

Wyświetl plik

@ -0,0 +1,32 @@
"""Unique const for addr
Revision ID: ea8185bd24c7
Revises: 40871a7807f6
Create Date: 2021-08-18 09:41:00.512462
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'ea8185bd24c7'
down_revision = '40871a7807f6'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index('ix_ethereum_addresses_address', table_name='ethereum_addresses')
op.create_index(op.f('ix_ethereum_addresses_address'), 'ethereum_addresses', ['address'], unique=True)
op.create_unique_constraint(op.f('uq_ethereum_labels_id'), 'ethereum_labels', ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(op.f('uq_ethereum_labels_id'), 'ethereum_labels', type_='unique')
op.drop_index(op.f('ix_ethereum_addresses_address'), table_name='ethereum_addresses')
op.create_index('ix_ethereum_addresses_address', 'ethereum_addresses', ['address'], unique=False)
# ### end Alembic commands ###

Wyświetl plik

@ -113,7 +113,7 @@ class EthereumAddress(Base): # type: ignore
nullable=True,
index=True,
)
address = Column(VARCHAR(256), nullable=False, index=True)
address = Column(VARCHAR(256), nullable=False, unique=True, index=True)
created_at = Column(
DateTime(timezone=True), server_default=utcnow(), nullable=False
)