"""base

Revision ID: 3895aa356acf
Revises: 
Create Date: 2019-05-19 11:34:12.741305

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '3895aa356acf'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('exam_questions',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('question', sa.String(length=200), nullable=True),
    sa.Column('question_type', sa.String(length=64), nullable=True),
    sa.Column('question_images', sa.Text(), nullable=True),
    sa.Column('option_a', sa.String(length=64), nullable=True),
    sa.Column('option_b', sa.String(length=64), nullable=True),
    sa.Column('option_c', sa.String(length=64), nullable=True),
    sa.Column('option_d', sa.String(length=64), nullable=True),
    sa.Column('answer', sa.String(length=1), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_exam_questions_question'), 'exam_questions', ['question'], unique=False)
    op.create_table('user',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=64), nullable=True),
    sa.Column('sagf_id', sa.Integer(), nullable=True),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('surname', sa.String(length=64), nullable=True),
    sa.Column('email', sa.String(length=128), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('enabled', sa.Boolean(), nullable=True),
    sa.Column('admin', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
    op.create_index(op.f('ix_user_sagf_id'), 'user', ['sagf_id'], unique=True)
    op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True)
    op.create_table('exam_result',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('sagf_id', sa.Integer(), nullable=True),
    sa.Column('theory_answer', sa.Text(), nullable=True),
    sa.Column('practical_answer', sa.Text(), nullable=True),
    sa.Column('exam_start_date', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['sagf_id'], ['user.sagf_id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('sagf_id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('exam_result')
    op.drop_index(op.f('ix_user_username'), table_name='user')
    op.drop_index(op.f('ix_user_sagf_id'), table_name='user')
    op.drop_index(op.f('ix_user_email'), table_name='user')
    op.drop_table('user')
    op.drop_index(op.f('ix_exam_questions_question'), table_name='exam_questions')
    op.drop_table('exam_questions')
    # ### end Alembic commands ###
