Add confirmed column to account

develop
esensar 2018-10-08 23:09:55 +02:00
parent 057e9e2b19
commit 79b4a23c4c
2 changed files with 42 additions and 0 deletions

View File

@ -13,6 +13,8 @@ class Account(db.Model):
email = db.Column(db.String, index=True, unique=True) email = db.Column(db.String, index=True, unique=True)
role_id = db.Column(db.Integer, db.ForeignKey("roles.id")) role_id = db.Column(db.Integer, db.ForeignKey("roles.id"))
role = db.relationship("Role", foreign_keys=[role_id]) role = db.relationship("Role", foreign_keys=[role_id])
confirmed = db.Column(db.Boolean, default=False)
confirmed_at = db.Column(db.DateTime, nullable=True)
created_at = db.Column(db.DateTime, created_at = db.Column(db.DateTime,
nullable=False, nullable=False,
default=db.func.current_timestamp()) default=db.func.current_timestamp())

View File

@ -0,0 +1,40 @@
"""empty message
Revision ID: fd5cfe0f1c51
Revises: 55611f1868bd
Create Date: 2018-10-08 23:07:48.054401
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'fd5cfe0f1c51'
down_revision = '55611f1868bd'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('accounts', sa.Column('confirmed', sa.Boolean(), nullable=True))
op.add_column('accounts', sa.Column('confirmed_at', sa.DateTime(), nullable=True))
role = sa.table('roles', sa.column('id', sa.Integer),
sa.column('permissions', sa.ARRAY(sa.String)))
op.execute(role.update().where(role.c.id == op.inline_literal(1)).
values({'permissions':
['CREATE_DEVICE_TYPE', 'CREATE_ROLE',
'ASSIGN_ROLE',
'CREATE_DEVICE', 'CREATE_DASHBOARD',
'READ_DEVICE_TYPES', 'READ_ROLES']})
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('accounts', 'confirmed_at')
op.drop_column('accounts', 'confirmed')
# ### end Alembic commands ###