"""Added code and data to publications

Revision ID: 4b239be7667e
Revises:
Create Date: 2018-01-07 01:06:47.762287

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision = '4b239be7667e'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('migrate_version')
    op.add_column('papers', sa.Column('code', sa.String(length=300), nullable=True))
    op.add_column('papers', sa.Column('data', sa.String(length=300), nullable=True))
    op.create_index(op.f('ix_papers_abstract'), 'papers', ['abstract'], unique=False)
    op.create_index(op.f('ix_papers_citation'), 'papers', ['citation'], unique=True)
    op.create_index(op.f('ix_papers_code'), 'papers', ['code'], unique=True)
    op.create_index(op.f('ix_papers_data'), 'papers', ['data'], unique=True)
    op.create_index(op.f('ix_papers_link'), 'papers', ['link'], unique=True)
    op.create_index(op.f('ix_papers_nickname'), 'papers', ['nickname'], unique=True)
    op.add_column('users', sa.Column('cv', sa.String(length=120), nullable=True))
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('users', 'cv')
    op.drop_index(op.f('ix_papers_nickname'), table_name='papers')
    op.drop_index(op.f('ix_papers_link'), table_name='papers')
    op.drop_index(op.f('ix_papers_data'), table_name='papers')
    op.drop_index(op.f('ix_papers_code'), table_name='papers')
    op.drop_index(op.f('ix_papers_citation'), table_name='papers')
    op.drop_index(op.f('ix_papers_abstract'), table_name='papers')
    op.drop_column('papers', 'data')
    op.drop_column('papers', 'code')
    op.create_table('migrate_version',
    sa.Column('repository_id', mysql.VARCHAR(length=250), nullable=False),
    sa.Column('repository_path', mysql.TEXT(), nullable=True),
    sa.Column('version', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('repository_id'),
    mysql_default_charset=u'utf8',
    mysql_engine=u'MyISAM'
    )
    # ### end Alembic commands ###
