"""added gold_topic_annotation_id foreign key and details json column to aggregated_annotations table

Revision ID: 8a59ba074e88
Revises: 56979a27451f
Create Date: 2017-11-12 22:49:44.778069

"""

# revision identifiers, used by Alembic.
revision = '8a59ba074e88'
down_revision = '56979a27451f'
branch_labels = None
depends_on = None

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

def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('aggregated_annotations', sa.Column('details', postgresql.JSON(), nullable=True))
    op.add_column('aggregated_annotations', sa.Column('gold_topic_annotation_id', sa.BigInteger(), nullable=True))
    op.create_index(op.f('ix_aggregated_annotations_gold_topic_annotation_id'), 'aggregated_annotations', ['gold_topic_annotation_id'], unique=False)
    op.create_foreign_key(None, 'aggregated_annotations', 'topic_annotations', ['gold_topic_annotation_id'], ['id'])
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(None, 'aggregated_annotations', type_='foreignkey')
    op.drop_index(op.f('ix_aggregated_annotations_gold_topic_annotation_id'), table_name='aggregated_annotations')
    op.drop_column('aggregated_annotations', 'gold_topic_annotation_id')
    op.drop_column('aggregated_annotations', 'details')
    ### end Alembic commands ###
