"""add encoding for distribution list

Revision ID: 9f5525e84960
Revises: 6f3e327e3b87
Create Date: 2022-05-16 17:03:40.367755

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '9f5525e84960'
down_revision = '6f3e327e3b87'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('mirror_list', schema=None) as batch_op:
        batch_op.add_column(sa.Column('encoding', sa.String(length=20), nullable=True))

    with op.batch_alter_table('mirror_list', schema=None) as batch_op:
        batch_op.execute("UPDATE mirror_list SET encoding = 'json'")
        batch_op.alter_column('encoding', nullable=False)

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('mirror_list', schema=None) as batch_op:
        batch_op.drop_column('encoding')

    # ### end Alembic commands ###
