"""add a table for many to many rel

Revision ID: 33c539214f2c
Revises: 6d8048eda3a5
Create Date: 2019-03-06 22:19:57.949941

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '33c539214f2c'
down_revision = '6d8048eda3a5'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('joints',
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('answer_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['answer_id'], ['answers.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('user_id', 'answer_id')
    )
    op.drop_constraint('questions_user_id_fkey', 'questions', type_='foreignkey')
    op.drop_column('questions', 'user_id')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('questions', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key('questions_user_id_fkey', 'questions', 'users', ['user_id'], ['id'])
    op.drop_table('joints')
    # ### end Alembic commands ###
