"""Add constraint to playlist_tracks

Revision ID: 1c4048efee96
Revises: 52cbded98e7c
Create Date: 2022-03-29 19:26:27.378185

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

# revision identifiers, used by Alembic.
revision = '1c4048efee96'
down_revision = '52cbded98e7c'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_unique_constraint('uniquerow', 'playlist_tracks', ['row', 'playlist_id'])
    op.alter_column('playlists', 'loaded',
               existing_type=mysql.TINYINT(display_width=1),
               nullable=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('playlists', 'loaded',
               existing_type=mysql.TINYINT(display_width=1),
               nullable=True)
    op.drop_constraint('uniquerow', 'playlist_tracks', type_='unique')
    # ### end Alembic commands ###
