"""add asset origins

Revision ID: c644bb20d0e3
Revises: 133961a48525
Create Date: 2022-05-25 15:21:16.221418

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'c644bb20d0e3'
down_revision = '133961a48525'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('origin', schema=None) as batch_op:
        batch_op.add_column(sa.Column('assets', sa.Boolean(), nullable=True))
    with op.batch_alter_table('origin', schema=None) as batch_op:
        batch_op.execute("UPDATE origin SET assets=false")
        batch_op.alter_column('assets',
               existing_type=sa.BOOLEAN(),
               nullable=False)

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('origin', schema=None) as batch_op:
        batch_op.alter_column('smart',
               existing_type=sa.BOOLEAN(),
               nullable=True)
        batch_op.drop_column('assets')

    # ### end Alembic commands ###
