From f2390ad26c8d646968153345b07087db991291ba Mon Sep 17 00:00:00 2001 From: esensar Date: Wed, 10 Oct 2018 21:07:27 +0200 Subject: [PATCH] Make confirmed column required --- app/accounts/models.py | 2 +- migrations/versions/ae43d7caad52_.py | 37 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 migrations/versions/ae43d7caad52_.py diff --git a/app/accounts/models.py b/app/accounts/models.py index 4600a62..e3fc958 100644 --- a/app/accounts/models.py +++ b/app/accounts/models.py @@ -13,7 +13,7 @@ class Account(db.Model): email = db.Column(db.String, index=True, unique=True) role_id = db.Column(db.Integer, db.ForeignKey("roles.id")) role = db.relationship("Role", foreign_keys=[role_id]) - confirmed = db.Column(db.Boolean, default=False) + confirmed = db.Column(db.Boolean, default=False, nullable=False) confirmed_at = db.Column(db.DateTime, nullable=True) created_at = db.Column(db.DateTime, nullable=False, diff --git a/migrations/versions/ae43d7caad52_.py b/migrations/versions/ae43d7caad52_.py new file mode 100644 index 0000000..57f1578 --- /dev/null +++ b/migrations/versions/ae43d7caad52_.py @@ -0,0 +1,37 @@ +"""empty message + +Revision ID: ae43d7caad52 +Revises: fd5cfe0f1c51 +Create Date: 2018-10-10 21:01:06.071591 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'ae43d7caad52' +down_revision = 'fd5cfe0f1c51' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + accounts = sa.table('accounts', sa.column('id', sa.Integer), + sa.column('confirmed', sa.BOOLEAN())) + op.execute(accounts.update(). + values({'confirmed': True})) + + op.alter_column('accounts', 'confirmed', + existing_type=sa.BOOLEAN(), + nullable=False) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('accounts', 'confirmed', + existing_type=sa.BOOLEAN(), + nullable=True) + # ### end Alembic commands ###