"""ADD user disabled field

Revision ID: 074fa1ed980b
Revises: 58166a4719aa
Create Date: 2022-01-16 02:09:29.582575

"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = "074fa1ed980b"
down_revision = "58166a4719aa"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column("user", sa.Column("disabled", sa.Boolean()))
    conn = op.get_bind()
    conn.execute('update user set disabled = 0;')
    op.alter_column(
        "user",
        "disabled",
        existing_type=mysql.BOOLEAN(),
        nullable=False,
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("user", "disabled")
    # ### end Alembic commands ###
