"""add tags

Revision ID: c2913fc17416
Revises: fe7d4cd37fda
Create Date: 2019-10-10 16:49:50.403179

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'c2913fc17416'
down_revision = 'fe7d4cd37fda'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('tag',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('tagname', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_tag')),
    sa.UniqueConstraint('tagname', name=op.f('uq_tag_tagname'))
    )
    op.create_table('tag_recipes',
    sa.Column('recipe_id', sa.Integer(), nullable=True),
    sa.Column('tag_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['recipe_id'], ['recipe.id'], name=op.f('fk_tag_recipes_recipe_id_recipe')),
    sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], name=op.f('fk_tag_recipes_tag_id_tag'))
    )
    with op.batch_alter_table('recipe', schema=None) as batch_op:
        batch_op.drop_column('likes')

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('recipe', schema=None) as batch_op:
        batch_op.add_column(sa.Column('likes', sa.INTEGER(), autoincrement=False, nullable=True))

    op.drop_table('tag_recipes')
    op.drop_table('tag')
    # ### end Alembic commands ###
