# -*- coding: utf-8 -*-
"""empty message

Revision ID: roc_dingo_0006_add_is_removed
Revises: roc_dingo_0005_mv_type_level
Create Date: 2020-11-20 13:53:36.510543

"""

from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = "roc_dingo_0006_add_is_removed"
down_revision = "roc_dingo_0005_mv_type_level"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "file_log",
        sa.Column("is_removed", sa.BOOLEAN(), nullable=True),
        schema="pipeline",
    )

    # adding a column with a default value is not possible with Alembic
    # so create the column without the nullable constraint
    # fill the table with the default value (false)
    # after, add the nullable constraint

    op.execute("UPDATE pipeline.file_log SET is_removed = false")
    op.alter_column("file_log", "is_removed", nullable=False, schema="pipeline")

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###

    op.drop_column("file_log", "is_removed", schema="pipeline")
    # ### end Alembic commands ###
