"""list: make id a string, rename name -> display

Revision ID: b092089c847f
Revises: df7526f9612b
Create Date: 2025-12-08 21:57:12.351774

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'b092089c847f'
down_revision = 'df7526f9612b'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('email_in', schema=None) as batch_op:
        batch_op.alter_column('list_id',
               existing_type=sa.INTEGER(),
               type_=sa.String(),
               nullable=False)

    with op.batch_alter_table('email_out', schema=None) as batch_op:
        batch_op.alter_column('list_id',
               existing_type=sa.INTEGER(),
               type_=sa.String(),
               existing_nullable=True)

    with op.batch_alter_table('list', schema=None) as batch_op:
        batch_op.alter_column('id',
               existing_type=sa.INTEGER(),
               type_=sa.String(),
               existing_nullable=False)
        batch_op.alter_column('name', new_column_name='display')

    with op.batch_alter_table('logs', schema=None) as batch_op:
        batch_op.alter_column('list_id',
               existing_type=sa.INTEGER(),
               type_=sa.String(),
               existing_nullable=True)

    with op.batch_alter_table('subscriber', schema=None) as batch_op:
        batch_op.alter_column('list_id',
               existing_type=sa.INTEGER(),
               type_=sa.String(),
               existing_nullable=False)

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('subscriber', schema=None) as batch_op:
        batch_op.alter_column('list_id',
               existing_type=sa.String(),
               type_=sa.INTEGER(),
               existing_nullable=False)

    with op.batch_alter_table('logs', schema=None) as batch_op:
        batch_op.alter_column('list_id',
               existing_type=sa.String(),
               type_=sa.INTEGER(),
               existing_nullable=True)

    with op.batch_alter_table('list', schema=None) as batch_op:
        batch_op.alter_column('id',
               existing_type=sa.String(),
               type_=sa.INTEGER(),
               existing_nullable=False)
        batch_op.alter_column('display', new_column_name='name')

    with op.batch_alter_table('email_out', schema=None) as batch_op:
        batch_op.alter_column('list_id',
               existing_type=sa.String(),
               type_=sa.INTEGER(),
               existing_nullable=True)

    with op.batch_alter_table('email_in', schema=None) as batch_op:
        batch_op.alter_column('list_id',
               existing_type=sa.String(),
               type_=sa.INTEGER(),
               nullable=True)

    # ### end Alembic commands ###
