"""user topic association

Revision ID: 461f7ff5389d
Revises: 59a33897c804
Create Date: 2019-01-28 13:12:21.229878

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

# revision identifiers, used by Alembic.
revision = '461f7ff5389d'
down_revision = '59a33897c804'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('association',
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('topic_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['topic_id'], ['topic.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('user_id', 'topic_id')
    )
    op.drop_constraint(u'post_ibfk_2', 'post', type_='foreignkey')
    op.drop_column(u'post', 'topic')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(u'post', sa.Column('topic', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True))
    op.create_foreign_key(u'post_ibfk_2', 'post', 'topic', ['topic'], ['id'])
    op.drop_table('association')
    # ### end Alembic commands ###
