"""updated my_collections table

Revision ID: 6133e3437d5c
Revises: 0a35a77d5be7
Create Date: 2021-07-13 18:44:38.254301

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '6133e3437d5c'
down_revision = '0a35a77d5be7'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('music_posts', sa.Column('by', sa.String(length=40), nullable=True))
    op.add_column('my_collections', sa.Column('music_post_id', sa.Integer(), nullable=True))
    op.alter_column('my_collections', 'user_id',
               existing_type=sa.INTEGER(),
               nullable=False)
    op.drop_constraint('my_collections_song_id_fkey', 'my_collections', type_='foreignkey')
    op.create_foreign_key(None, 'my_collections', 'music_posts', ['music_post_id'], ['id'])
    op.create_foreign_key(None, 'my_collections', 'merchandise', ['merchandise_id'], ['id'])
    op.drop_column('my_collections', 'song_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('my_collections', sa.Column('song_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'my_collections', type_='foreignkey')
    op.drop_constraint(None, 'my_collections', type_='foreignkey')
    op.create_foreign_key('my_collections_song_id_fkey', 'my_collections', 'songs', ['song_id'], ['id'])
    op.alter_column('my_collections', 'user_id',
               existing_type=sa.INTEGER(),
               nullable=True)
    op.drop_column('my_collections', 'music_post_id')
    op.drop_column('music_posts', 'by')
    # ### end Alembic commands ###
