"""Add UserExpertTopic model.

Revision ID: 7183a00cf0c
Revises: 2f41be73a5ba
Create Date: 2015-05-30 10:02:24.705054

"""

# revision identifiers, used by Alembic.
revision = '7183a00cf0c'
down_revision = '2f41be73a5ba'

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

def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user_expert_topic',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('show_order', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('topic_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['topic_id'], ['topic.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user_topic_statistics',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('upvotes_count', sa.Integer(), nullable=True),
    sa.Column('answers_count', sa.Integer(), nullable=True),
    sa.Column('score', sa.Integer(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('topic_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['topic_id'], ['topic.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.drop_table('topic_expert')
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('topic_expert',
    sa.Column('id', mysql.INTEGER(display_width=11), nullable=False),
    sa.Column('upvotes_count', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.Column('answers_count', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.Column('created_at', mysql.DATETIME(), nullable=True),
    sa.Column('topic_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.Column('user_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.Column('score', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['topic_id'], [u'topic.id'], name=u'topic_expert_ibfk_1'),
    sa.ForeignKeyConstraint(['user_id'], [u'user.id'], name=u'topic_expert_ibfk_2'),
    sa.PrimaryKeyConstraint('id'),
    mysql_default_charset=u'utf8',
    mysql_engine=u'InnoDB'
    )
    op.drop_table('user_topic_statistics')
    op.drop_table('user_expert_topic')
    ### end Alembic commands ###
