"""restructure forum models

Revision ID: 2a1165f6ad0a
Revises: a3fb8937ae16
Create Date: 2019-09-07 19:38:57.472404

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '2a1165f6ad0a'
down_revision = 'a3fb8937ae16'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint('thread_id_fkey', 'thread', type_='foreignkey')
    op.drop_column('thread', 'title')
    op.drop_column('thread', 'thread_type')
    op.add_column('topic', sa.Column('thread_id', sa.Integer(), nullable=False))
    op.add_column('topic', sa.Column('title', sa.Unicode(length=32), nullable=True))
    op.drop_constraint('topic_id_fkey', 'topic', type_='foreignkey')
    op.create_foreign_key(None, 'topic', 'post', ['id'], ['id'])
    op.create_foreign_key(None, 'topic', 'thread', ['thread_id'], ['id'])
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'topic', type_='foreignkey')
    op.drop_constraint(None, 'topic', type_='foreignkey')
    op.create_foreign_key('topic_id_fkey', 'topic', 'thread', ['id'], ['id'])
    op.drop_column('topic', 'title')
    op.drop_column('topic', 'thread_id')
    op.add_column('thread', sa.Column('thread_type', sa.VARCHAR(length=20), autoincrement=False, nullable=True))
    op.add_column('thread', sa.Column('title', sa.VARCHAR(length=32), autoincrement=False, nullable=True))
    op.create_foreign_key('thread_id_fkey', 'thread', 'post', ['id'], ['id'])
    # ### end Alembic commands ###
