diff --git a/cookie_api/models.py b/cookie_api/models.py index ff75feb..e36bc97 100644 --- a/cookie_api/models.py +++ b/cookie_api/models.py @@ -64,6 +64,7 @@ class User(DBMixin, Base): password = Column(String(255)) admin = Column(Boolean, nullable=False, default=False) confirmed = Column(Boolean, nullable=False, default=False) + active = Column(Boolean, nullable=False, default=True) def __init__(self, email, password, admin=False): self.email = email diff --git a/migrations/versions/7c2d43ec9c84_adding_user_active_attribute.py b/migrations/versions/7c2d43ec9c84_adding_user_active_attribute.py new file mode 100644 index 0000000..a5fbbf3 --- /dev/null +++ b/migrations/versions/7c2d43ec9c84_adding_user_active_attribute.py @@ -0,0 +1,30 @@ +"""Adding user active attribute + +Revision ID: 7c2d43ec9c84 +Revises: 374c36260db7 +Create Date: 2018-06-10 17:57:32.570036 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '7c2d43ec9c84' +down_revision = '374c36260db7' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('users', sa.Column('active', sa.Boolean())) + op.execute('UPDATE users SET active = True') + op.alter_column('users', 'active', nullable=False) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('users', 'active') + # ### end Alembic commands ###