"""ADD assignment email enable

Revision ID: d5de41411043
Revises: 4f7efe8d8177
Create Date: 2022-08-31 17:56:55.711499

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

# revision identifiers, used by Alembic.
revision = "d5de41411043"
down_revision = "4f7efe8d8177"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "assignment",
        sa.Column(
            "email_notifications_enabled", sa.Boolean(),
        ),
    )
    conn = op.get_bind()
    conn.execute('UPDATE `assignment` SET `email_notifications_enabled` = 1;')
    op.alter_column('assignment', 'email_notifications_enabled', type_=sa.Boolean(), nullable=False)
    # ### end Alembic commands ###


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