back/users: make user names unique
This commit is contained in:
parent
888f095ef0
commit
44c34e5785
2 changed files with 21 additions and 1 deletions
|
@ -0,0 +1,20 @@
|
||||||
|
'''
|
||||||
|
Add unique constraint to the user name
|
||||||
|
|
||||||
|
Revision ID: d186d2e9c2c9
|
||||||
|
Created at: 2016-03-28 10:21:30.440333
|
||||||
|
'''
|
||||||
|
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
revision = 'd186d2e9c2c9'
|
||||||
|
down_revision = 'e5c1216a8503'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.create_unique_constraint('uq_user_name', 'user', ['name'])
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_constraint('uq_user_name', 'user', type_='unique')
|
|
@ -5,7 +5,7 @@ class User(Base):
|
||||||
__tablename__ = 'user'
|
__tablename__ = 'user'
|
||||||
|
|
||||||
user_id = sa.Column('id', sa.Integer, primary_key=True)
|
user_id = sa.Column('id', sa.Integer, primary_key=True)
|
||||||
name = sa.Column('name', sa.String(50), nullable=False)
|
name = sa.Column('name', sa.String(50), nullable=False, unique=True)
|
||||||
password_hash = sa.Column('password_hash', sa.String(64), nullable=False)
|
password_hash = sa.Column('password_hash', sa.String(64), nullable=False)
|
||||||
password_salt = sa.Column('pasword_salt', sa.String(32))
|
password_salt = sa.Column('pasword_salt', sa.String(32))
|
||||||
email = sa.Column('email', sa.String(200), nullable=True)
|
email = sa.Column('email', sa.String(200), nullable=True)
|
||||||
|
|
Loading…
Reference in a new issue