"""Fix cascade

Revision ID: 7b11c2291b8f
Revises: b5e309bfc338
Create Date: 2019-09-30 01:34:27.469599

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '7b11c2291b8f'
down_revision = 'b5e309bfc338'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('chat_current_task_id_fkey', 'chat', type_='foreignkey')
    op.create_foreign_key('chat_current_task_id_fkey', 'chat', 'task', ['current_task_id'], ['id'], ondelete='SET NULL')
    op.alter_column('user', 'notifications',
               existing_type=sa.BOOLEAN(),
               server_default=None,
               existing_nullable=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('user', 'notifications',
               existing_type=sa.BOOLEAN(),
               server_default=sa.text('true'),
               existing_nullable=False)
    op.drop_constraint('chat_current_task_id_fkey', 'chat', type_='foreignkey')
    op.create_foreign_key('chat_current_task_id_fkey', 'chat', 'task', ['current_task_id'], ['id'], ondelete='CASCADE')
    # ### end Alembic commands ###