"""Initial migration

Revision ID: 708a21f5c271
Revises: 
Create Date: 2024-12-14 11:16:09.067598

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

# revision identifiers, used by Alembic.
revision = '708a21f5c271'
down_revision = None
branch_labels = None
depends_on = None


def upgrade(engine_name: str) -> None:
    globals()["upgrade_%s" % engine_name]()


def downgrade(engine_name: str) -> None:
    globals()["downgrade_%s" % engine_name]()





def upgrade_() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('carts', schema=None) as batch_op:
        batch_op.drop_index('cart_number')
        batch_op.drop_index('ix_carts_duration')
        batch_op.drop_index('ix_carts_name')

    op.drop_table('carts')
    with op.batch_alter_table('notecolours', schema=None) as batch_op:
        batch_op.add_column(sa.Column('foreground', sa.String(length=21), nullable=True))

    with op.batch_alter_table('playlist_rows', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_playlist_rows_playlist_id'), ['playlist_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_playlist_rows_row_number'), ['row_number'], unique=False)

    # ### end Alembic commands ###


def downgrade_() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('playlist_rows', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_playlist_rows_row_number'))
        batch_op.drop_index(batch_op.f('ix_playlist_rows_playlist_id'))

    with op.batch_alter_table('notecolours', schema=None) as batch_op:
        batch_op.drop_column('foreground')

    op.create_table('carts',
    sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
    sa.Column('cart_number', mysql.INTEGER(display_width=11), autoincrement=False, nullable=False),
    sa.Column('name', mysql.VARCHAR(length=256), nullable=False),
    sa.Column('duration', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.Column('path', mysql.VARCHAR(length=2048), nullable=True),
    sa.Column('enabled', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id'),
    mysql_collate='utf8mb4_general_ci',
    mysql_default_charset='utf8mb4',
    mysql_engine='InnoDB'
    )
    with op.batch_alter_table('carts', schema=None) as batch_op:
        batch_op.create_index('ix_carts_name', ['name'], unique=False)
        batch_op.create_index('ix_carts_duration', ['duration'], unique=False)
        batch_op.create_index('cart_number', ['cart_number'], unique=True)

    # ### end Alembic commands ###

