"""Add playlist and item models

Revision ID: 979da9b7aff0
Revises: <PASSWORD>
Create Date: 2021-10-31 13:09:14.064217

"""
from alembic import op
import sqlalchemy as sa
import sqlmodel


# revision identifiers, used by Alembic.
revision = '979da9b7aff0'
down_revision = 'a<PASSWORD>'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('item',
    sa.Column('title', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('artist', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('id', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_item_artist'), 'item', ['artist'], unique=False)
    op.create_index(op.f('ix_item_id'), 'item', ['id'], unique=False)
    op.create_index(op.f('ix_item_title'), 'item', ['title'], unique=False)
    op.create_table('playlist',
    sa.Column('entity_id', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('spotify', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('amazon', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('apple_music', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('image', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('release_date', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=True),
    sa.Column('category_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['category_id'], ['category.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_playlist_amazon'), 'playlist', ['amazon'], unique=False)
    op.create_index(op.f('ix_playlist_apple_music'), 'playlist', ['apple_music'], unique=False)
    op.create_index(op.f('ix_playlist_category_id'), 'playlist', ['category_id'], unique=False)
    op.create_index(op.f('ix_playlist_entity_id'), 'playlist', ['entity_id'], unique=False)
    op.create_index(op.f('ix_playlist_id'), 'playlist', ['id'], unique=False)
    op.create_index(op.f('ix_playlist_image'), 'playlist', ['image'], unique=False)
    op.create_index(op.f('ix_playlist_name'), 'playlist', ['name'], unique=False)
    op.create_index(op.f('ix_playlist_release_date'), 'playlist', ['release_date'], unique=False)
    op.create_index(op.f('ix_playlist_spotify'), 'playlist', ['spotify'], unique=False)
    op.create_table('playlistitemlink',
    sa.Column('playlist_id', sa.Integer(), nullable=True),
    sa.Column('item_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['item_id'], ['item.id'], ),
    sa.ForeignKeyConstraint(['playlist_id'], ['playlist.id'], ),
    sa.PrimaryKeyConstraint('playlist_id', 'item_id')
    )
    op.create_index(op.f('ix_playlistitemlink_item_id'), 'playlistitemlink', ['item_id'], unique=False)
    op.create_index(op.f('ix_playlistitemlink_playlist_id'), 'playlistitemlink', ['playlist_id'], unique=False)
    op.drop_index('ix_category_playlists', table_name='category')
    op.drop_column('category', 'playlists')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('category', sa.Column('playlists', sa.VARCHAR(), nullable=False))
    op.create_index('ix_category_playlists', 'category', ['playlists'], unique=False)
    op.drop_index(op.f('ix_playlistitemlink_playlist_id'), table_name='playlistitemlink')
    op.drop_index(op.f('ix_playlistitemlink_item_id'), table_name='playlistitemlink')
    op.drop_table('playlistitemlink')
    op.drop_index(op.f('ix_playlist_spotify'), table_name='playlist')
    op.drop_index(op.f('ix_playlist_release_date'), table_name='playlist')
    op.drop_index(op.f('ix_playlist_name'), table_name='playlist')
    op.drop_index(op.f('ix_playlist_image'), table_name='playlist')
    op.drop_index(op.f('ix_playlist_id'), table_name='playlist')
    op.drop_index(op.f('ix_playlist_entity_id'), table_name='playlist')
    op.drop_index(op.f('ix_playlist_category_id'), table_name='playlist')
    op.drop_index(op.f('ix_playlist_apple_music'), table_name='playlist')
    op.drop_index(op.f('ix_playlist_amazon'), table_name='playlist')
    op.drop_table('playlist')
    op.drop_index(op.f('ix_item_title'), table_name='item')
    op.drop_index(op.f('ix_item_id'), table_name='item')
    op.drop_index(op.f('ix_item_artist'), table_name='item')
    op.drop_table('item')
    # ### end Alembic commands ###

sqlmodel.sql.sqltypes.AutoString alembic.op.drop_index sqlalchemy.VARCHAR sqlalchemy.Integer alembic.op.drop_table sqlalchemy.PrimaryKeyConstraint sqlalchemy.DateTime alembic.op.create_index alembic.op.f sqlalchemy.ForeignKeyConstraint alembic.op.drop_column
[((3030, 3091), 'alembic.op.drop_index', 'op.drop_index', (['"""ix_category_playlists"""'], {'table_name': '"""category"""'}), "('ix_category_playlists', table_name='category')\n", (3043, 3091), False, 'from alembic import op\n'), ((3096, 3135), 'alembic.op.drop_column', 'op.drop_column', (['"""category"""', '"""playlists"""'], {}), "('category', 'playlists')\n", (3110, 3135), False, 'from alembic import op\n'), ((3344, 3430), 'alembic.op.create_index', 'op.create_index', (['"""ix_category_playlists"""', '"""category"""', "['playlists']"], {'unique': '(False)'}), "('ix_category_playlists', 'category', ['playlists'], unique=\n    False)\n", (3359, 3430), False, 'from alembic import op\n'), ((3606, 3639), 'alembic.op.drop_table', 'op.drop_table', (['"""playlistitemlink"""'], {}), "('playlistitemlink')\n", (3619, 3639), False, 'from alembic import op\n'), ((4278, 4303), 'alembic.op.drop_table', 'op.drop_table', (['"""playlist"""'], {}), "('playlist')\n", (4291, 4303), False, 'from alembic import op\n'), ((4486, 4507), 'alembic.op.drop_table', 'op.drop_table', (['"""item"""'], {}), "('item')\n", (4499, 4507), False, 'from alembic import op\n'), ((643, 672), 'sqlalchemy.PrimaryKeyConstraint', 'sa.PrimaryKeyConstraint', (['"""id"""'], {}), "('id')\n", (666, 672), True, 'import sqlalchemy as sa\n'), ((699, 721), 'alembic.op.f', 'op.f', (['"""ix_item_artist"""'], {}), "('ix_item_artist')\n", (703, 721), False, 'from alembic import op\n'), ((777, 795), 'alembic.op.f', 'op.f', (['"""ix_item_id"""'], {}), "('ix_item_id')\n", (781, 795), False, 'from alembic import op\n'), ((847, 868), 'alembic.op.f', 'op.f', (['"""ix_item_title"""'], {}), "('ix_item_title')\n", (851, 868), False, 'from alembic import op\n'), ((1573, 1630), 'sqlalchemy.ForeignKeyConstraint', 'sa.ForeignKeyConstraint', (["['category_id']", "['category.id']"], {}), "(['category_id'], ['category.id'])\n", (1596, 1630), True, 'import sqlalchemy as sa\n'), ((1638, 1667), 'sqlalchemy.PrimaryKeyConstraint', 'sa.PrimaryKeyConstraint', (['"""id"""'], {}), "('id')\n", (1661, 1667), True, 'import sqlalchemy as sa\n'), ((1694, 1720), 'alembic.op.f', 'op.f', (['"""ix_playlist_amazon"""'], {}), "('ix_playlist_amazon')\n", (1698, 1720), False, 'from alembic import op\n'), ((1780, 1811), 'alembic.op.f', 'op.f', (['"""ix_playlist_apple_music"""'], {}), "('ix_playlist_apple_music')\n", (1784, 1811), False, 'from alembic import op\n'), ((1876, 1907), 'alembic.op.f', 'op.f', (['"""ix_playlist_category_id"""'], {}), "('ix_playlist_category_id')\n", (1880, 1907), False, 'from alembic import op\n'), ((1972, 2001), 'alembic.op.f', 'op.f', (['"""ix_playlist_entity_id"""'], {}), "('ix_playlist_entity_id')\n", (1976, 2001), False, 'from alembic import op\n'), ((2064, 2086), 'alembic.op.f', 'op.f', (['"""ix_playlist_id"""'], {}), "('ix_playlist_id')\n", (2068, 2086), False, 'from alembic import op\n'), ((2142, 2167), 'alembic.op.f', 'op.f', (['"""ix_playlist_image"""'], {}), "('ix_playlist_image')\n", (2146, 2167), False, 'from alembic import op\n'), ((2226, 2250), 'alembic.op.f', 'op.f', (['"""ix_playlist_name"""'], {}), "('ix_playlist_name')\n", (2230, 2250), False, 'from alembic import op\n'), ((2308, 2340), 'alembic.op.f', 'op.f', (['"""ix_playlist_release_date"""'], {}), "('ix_playlist_release_date')\n", (2312, 2340), False, 'from alembic import op\n'), ((2406, 2433), 'alembic.op.f', 'op.f', (['"""ix_playlist_spotify"""'], {}), "('ix_playlist_spotify')\n", (2410, 2433), False, 'from alembic import op\n'), ((2632, 2681), 'sqlalchemy.ForeignKeyConstraint', 'sa.ForeignKeyConstraint', (["['item_id']", "['item.id']"], {}), "(['item_id'], ['item.id'])\n", (2655, 2681), True, 'import sqlalchemy as sa\n'), ((2689, 2746), 'sqlalchemy.ForeignKeyConstraint', 'sa.ForeignKeyConstraint', (["['playlist_id']", "['playlist.id']"], {}), "(['playlist_id'], ['playlist.id'])\n", (2712, 2746), True, 'import sqlalchemy as sa\n'), ((2754, 2803), 'sqlalchemy.PrimaryKeyConstraint', 'sa.PrimaryKeyConstraint', (['"""playlist_id"""', '"""item_id"""'], {}), "('playlist_id', 'item_id')\n", (2777, 2803), True, 'import sqlalchemy as sa\n'), ((2830, 2865), 'alembic.op.f', 'op.f', (['"""ix_playlistitemlink_item_id"""'], {}), "('ix_playlistitemlink_item_id')\n", (2834, 2865), False, 'from alembic import op\n'), ((2934, 2973), 'alembic.op.f', 'op.f', (['"""ix_playlistitemlink_playlist_id"""'], {}), "('ix_playlistitemlink_playlist_id')\n", (2938, 2973), False, 'from alembic import op\n'), ((3444, 3483), 'alembic.op.f', 'op.f', (['"""ix_playlistitemlink_playlist_id"""'], {}), "('ix_playlistitemlink_playlist_id')\n", (3448, 3483), False, 'from alembic import op\n'), ((3534, 3569), 'alembic.op.f', 'op.f', (['"""ix_playlistitemlink_item_id"""'], {}), "('ix_playlistitemlink_item_id')\n", (3538, 3569), False, 'from alembic import op\n'), ((3658, 3685), 'alembic.op.f', 'op.f', (['"""ix_playlist_spotify"""'], {}), "('ix_playlist_spotify')\n", (3662, 3685), False, 'from alembic import op\n'), ((3728, 3760), 'alembic.op.f', 'op.f', (['"""ix_playlist_release_date"""'], {}), "('ix_playlist_release_date')\n", (3732, 3760), False, 'from alembic import op\n'), ((3803, 3827), 'alembic.op.f', 'op.f', (['"""ix_playlist_name"""'], {}), "('ix_playlist_name')\n", (3807, 3827), False, 'from alembic import op\n'), ((3870, 3895), 'alembic.op.f', 'op.f', (['"""ix_playlist_image"""'], {}), "('ix_playlist_image')\n", (3874, 3895), False, 'from alembic import op\n'), ((3938, 3960), 'alembic.op.f', 'op.f', (['"""ix_playlist_id"""'], {}), "('ix_playlist_id')\n", (3942, 3960), False, 'from alembic import op\n'), ((4003, 4032), 'alembic.op.f', 'op.f', (['"""ix_playlist_entity_id"""'], {}), "('ix_playlist_entity_id')\n", (4007, 4032), False, 'from alembic import op\n'), ((4075, 4106), 'alembic.op.f', 'op.f', (['"""ix_playlist_category_id"""'], {}), "('ix_playlist_category_id')\n", (4079, 4106), False, 'from alembic import op\n'), ((4149, 4180), 'alembic.op.f', 'op.f', (['"""ix_playlist_apple_music"""'], {}), "('ix_playlist_apple_music')\n", (4153, 4180), False, 'from alembic import op\n'), ((4223, 4249), 'alembic.op.f', 'op.f', (['"""ix_playlist_amazon"""'], {}), "('ix_playlist_amazon')\n", (4227, 4249), False, 'from alembic import op\n'), ((4322, 4343), 'alembic.op.f', 'op.f', (['"""ix_item_title"""'], {}), "('ix_item_title')\n", (4326, 4343), False, 'from alembic import op\n'), ((4382, 4400), 'alembic.op.f', 'op.f', (['"""ix_item_id"""'], {}), "('ix_item_id')\n", (4386, 4400), False, 'from alembic import op\n'), ((4439, 4461), 'alembic.op.f', 'op.f', (['"""ix_item_artist"""'], {}), "('ix_item_artist')\n", (4443, 4461), False, 'from alembic import op\n'), ((459, 493), 'sqlmodel.sql.sqltypes.AutoString', 'sqlmodel.sql.sqltypes.AutoString', ([], {}), '()\n', (491, 493), False, 'import sqlmodel\n'), ((536, 570), 'sqlmodel.sql.sqltypes.AutoString', 'sqlmodel.sql.sqltypes.AutoString', ([], {}), '()\n', (568, 570), False, 'import sqlmodel\n'), ((609, 621), 'sqlalchemy.Integer', 'sa.Integer', ([], {}), '()\n', (619, 621), True, 'import sqlalchemy as sa\n'), ((962, 996), 'sqlmodel.sql.sqltypes.AutoString', 'sqlmodel.sql.sqltypes.AutoString', ([], {}), '()\n', (994, 996), False, 'import sqlmodel\n'), ((1037, 1071), 'sqlmodel.sql.sqltypes.AutoString', 'sqlmodel.sql.sqltypes.AutoString', ([], {}), '()\n', (1069, 1071), False, 'import sqlmodel\n'), ((1115, 1149), 'sqlmodel.sql.sqltypes.AutoString', 'sqlmodel.sql.sqltypes.AutoString', ([], {}), '()\n', (1147, 1149), False, 'import sqlmodel\n'), ((1191, 1225), 'sqlmodel.sql.sqltypes.AutoString', 'sqlmodel.sql.sqltypes.AutoString', ([], {}), '()\n', (1223, 1225), False, 'import sqlmodel\n'), ((1272, 1306), 'sqlmodel.sql.sqltypes.AutoString', 'sqlmodel.sql.sqltypes.AutoString', ([], {}), '()\n', (1304, 1306), False, 'import sqlmodel\n'), ((1347, 1381), 'sqlmodel.sql.sqltypes.AutoString', 'sqlmodel.sql.sqltypes.AutoString', ([], {}), '()\n', (1379, 1381), False, 'import sqlmodel\n'), ((1429, 1442), 'sqlalchemy.DateTime', 'sa.DateTime', ([], {}), '()\n', (1440, 1442), True, 'import sqlalchemy as sa\n'), ((1480, 1492), 'sqlalchemy.Integer', 'sa.Integer', ([], {}), '()\n', (1490, 1492), True, 'import sqlalchemy as sa\n'), ((1539, 1551), 'sqlalchemy.Integer', 'sa.Integer', ([], {}), '()\n', (1549, 1551), True, 'import sqlalchemy as sa\n'), ((2543, 2555), 'sqlalchemy.Integer', 'sa.Integer', ([], {}), '()\n', (2553, 2555), True, 'import sqlalchemy as sa\n'), ((2598, 2610), 'sqlalchemy.Integer', 'sa.Integer', ([], {}), '()\n', (2608, 2610), True, 'import sqlalchemy as sa\n'), ((3309, 3321), 'sqlalchemy.VARCHAR', 'sa.VARCHAR', ([], {}), '()\n', (3319, 3321), True, 'import sqlalchemy as sa\n')]