Fix migration script and user model

This commit is contained in:
Khanh Ngo 2019-12-22 08:40:05 +07:00
parent 4bdd433079
commit d09a645300
No known key found for this signature in database
GPG Key ID: A945965CD6351844
2 changed files with 4 additions and 3 deletions

View File

@ -8,7 +8,6 @@ Create Date: 2019-12-21 17:11:36.564632
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = '3f76448bb6de' revision = '3f76448bb6de'
down_revision = 'b0fea72a3f20' down_revision = 'b0fea72a3f20'
@ -18,7 +17,9 @@ depends_on = None
def upgrade(): def upgrade():
with op.batch_alter_table('user') as batch_op: with op.batch_alter_table('user') as batch_op:
batch_op.add_column(sa.Column('confirmed', sa.Boolean())) batch_op.add_column(
sa.Column('confirmed', sa.Boolean(), nullable=False,
default=False))
def downgrade(): def downgrade():

View File

@ -26,7 +26,7 @@ class User(db.Model):
lastname = db.Column(db.String(64)) lastname = db.Column(db.String(64))
email = db.Column(db.String(128)) email = db.Column(db.String(128))
otp_secret = db.Column(db.String(16)) otp_secret = db.Column(db.String(16))
confirmed = db.Column(db.SmallInteger, default=0) confirmed = db.Column(db.SmallInteger, nullable=False, default=0)
role_id = db.Column(db.Integer, db.ForeignKey('role.id')) role_id = db.Column(db.Integer, db.ForeignKey('role.id'))
def __init__(self, def __init__(self,