"""Add 'open' field to Playlists

Revision ID: 5bb2c572e1e5
Revises: 3a53a9fb26ab
Create Date: 2023-11-18 14:19:02.643914

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = '5bb2c572e1e5'
down_revision = '3a53a9fb26ab'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('carts', 'duration',
               existing_type=mysql.INTEGER(display_width=11),
               nullable=True)
    op.alter_column('carts', 'path',
               existing_type=mysql.VARCHAR(length=2048),
               nullable=True)
    op.alter_column('carts', 'enabled',
               existing_type=mysql.TINYINT(display_width=1),
               nullable=True)
    op.alter_column('playlist_rows', 'note',
               existing_type=mysql.VARCHAR(length=2048),
               nullable=False)
    op.add_column('playlists', sa.Column('open', sa.Boolean(), nullable=False))
    op.alter_column('settings', 'name',
               existing_type=mysql.VARCHAR(length=32),
               type_=sa.String(length=64),
               existing_nullable=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('settings', 'name',
               existing_type=sa.String(length=64),
               type_=mysql.VARCHAR(length=32),
               existing_nullable=False)
    op.drop_column('playlists', 'open')
    op.alter_column('playlist_rows', 'note',
               existing_type=mysql.VARCHAR(length=2048),
               nullable=True)
    op.alter_column('carts', 'enabled',
               existing_type=mysql.TINYINT(display_width=1),
               nullable=False)
    op.alter_column('carts', 'path',
               existing_type=mysql.VARCHAR(length=2048),
               nullable=False)
    op.alter_column('carts', 'duration',
               existing_type=mysql.INTEGER(display_width=11),
               nullable=False)
    # ### end Alembic commands ###
