"""empty message

Revision ID: 5392808c47f6
Revises: 1994a0e9e613
Create Date: 2016-10-12 00:27:33.591972

"""

# revision identifiers, used by Alembic.
revision = '5392808c47f6'
down_revision = '1994a0e9e613'

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

def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('fulltexts_extracted_data',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('created_at', sa.TIMESTAMP(), server_default=sa.text("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC')"), nullable=True),
    sa.Column('review_id', sa.Integer(), nullable=False),
    sa.Column('fulltext_id', sa.BigInteger(), nullable=False),
    sa.Column('extracted_data', postgresql.JSONB(none_as_null=True, astext_type=sa.Text()), server_default='{}', nullable=True),
    sa.ForeignKeyConstraint(['fulltext_id'], ['fulltexts.id'], ondelete='CASCADE'),
    sa.ForeignKeyConstraint(['review_id'], ['reviews.id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_fulltexts_extracted_data_fulltext_id'), 'fulltexts_extracted_data', ['fulltext_id'], unique=True)
    op.create_index(op.f('ix_fulltexts_extracted_data_review_id'), 'fulltexts_extracted_data', ['review_id'], unique=False)
    op.drop_column('fulltexts', 'extracted_data')
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('fulltexts', sa.Column('extracted_data', postgresql.JSONB(astext_type=sa.Text()), server_default=sa.text("'{}'::jsonb"), autoincrement=False, nullable=True))
    op.drop_index(op.f('ix_fulltexts_extracted_data_review_id'), table_name='fulltexts_extracted_data')
    op.drop_index(op.f('ix_fulltexts_extracted_data_fulltext_id'), table_name='fulltexts_extracted_data')
    op.drop_table('fulltexts_extracted_data')
    ### end Alembic commands ###
