"""add answer table

Revision ID: 8d7d01cccc3f
Revises: c54de427a522
Create Date: 2017-01-11 18:16:18.449300

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '8d7d01cccc3f'
down_revision = 'c54de427a522'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('answer',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('res_uid', sa.String(length=256), nullable=True),
    sa.Column('app_uid', sa.String(length=100), nullable=True),
    sa.Column('question', sa.String(length=255), nullable=True),
    sa.Column('time', sa.DateTime(), nullable=True),
    sa.Column('respondent', sa.String(length=20), nullable=True),
    sa.Column('age', sa.String(length=20), nullable=True),
    sa.Column('gender', sa.String(length=20), nullable=True),
    sa.Column('answer', sa.String(length=6), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_answer_age'), 'answer', ['age'], unique=False)
    op.create_index(op.f('ix_answer_answer'), 'answer', ['answer'], unique=False)
    op.create_index(op.f('ix_answer_app_uid'), 'answer', ['app_uid'], unique=False)
    op.create_index(op.f('ix_answer_gender'), 'answer', ['gender'], unique=False)
    op.create_index(op.f('ix_answer_id'), 'answer', ['id'], unique=False)
    op.create_index(op.f('ix_answer_question'), 'answer', ['question'], unique=False)
    op.create_index(op.f('ix_answer_res_uid'), 'answer', ['res_uid'], unique=False)
    op.create_index(op.f('ix_answer_respondent'), 'answer', ['respondent'], unique=False)
    op.create_index(op.f('ix_answer_time'), 'answer', ['time'], unique=False)
    op.add_column(u'question', sa.Column('app_uid', sa.String(length=100), nullable=True))
    op.create_index(op.f('ix_question_app_uid'), 'question', ['app_uid'], unique=False)
    op.add_column(u'upload file', sa.Column('app_uid', sa.String(length=100), nullable=True))
    op.create_index(op.f('ix_upload file_app_uid'), 'upload file', ['app_uid'], unique=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_upload file_app_uid'), table_name='upload file')
    op.drop_column(u'upload file', 'app_uid')
    op.drop_index(op.f('ix_question_app_uid'), table_name='question')
    op.drop_column(u'question', 'app_uid')
    op.drop_index(op.f('ix_answer_time'), table_name='answer')
    op.drop_index(op.f('ix_answer_respondent'), table_name='answer')
    op.drop_index(op.f('ix_answer_res_uid'), table_name='answer')
    op.drop_index(op.f('ix_answer_question'), table_name='answer')
    op.drop_index(op.f('ix_answer_id'), table_name='answer')
    op.drop_index(op.f('ix_answer_gender'), table_name='answer')
    op.drop_index(op.f('ix_answer_app_uid'), table_name='answer')
    op.drop_index(op.f('ix_answer_answer'), table_name='answer')
    op.drop_index(op.f('ix_answer_age'), table_name='answer')
    op.drop_table('answer')
    # ### end Alembic commands ###
