"""add_user_topics_table

Revision ID: 35c098d746fd
Revises: ac6e4c784f98
Create Date: 2017-08-17 12:55:24.557833

"""

# revision identifiers, used by Alembic.
revision = '35c098d746fd'
down_revision = 'ac6e4c784f98'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa
from sqlalchemy.schema import Sequence, CreateSequence

def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user_topics',
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('topic_id', sa.BigInteger(), nullable=True),
    sa.Column('user_id', sa.BigInteger(), nullable=True),
    sa.Column('following', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('user_id_following_topic_index', 'user_topics', ['user_id', 'following'], unique=False)
    ### end Alembic commands ###

    op.execute(CreateSequence(Sequence('user_topic_id_seq')))


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('user_id_following_topic_index', table_name='user_topics')
    op.drop_table('user_topics')
    ### end Alembic commands ###
