"""empty message

Revision ID: 5c62cd481200
Revises: 
Create Date: 2020-07-30 16:29:09.340880

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '5c62cd481200'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('publication_status',
    sa.Column('name', sa.VARCHAR(length=30), nullable=False),
    sa.PrimaryKeyConstraint('name', name=op.f('pk_publication_status'))
    )
    op.create_table('question_type',
    sa.Column('name', sa.VARCHAR(length=30), nullable=False),
    sa.PrimaryKeyConstraint('name', name=op.f('pk_question_type'))
    )
    op.create_table('role',
    sa.Column('name', sa.VARCHAR(length=30), nullable=False),
    sa.PrimaryKeyConstraint('name', name=op.f('pk_role'))
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('username', sa.VARCHAR(length=30), nullable=True),
    sa.Column('name', sa.VARCHAR(length=255), nullable=True),
    sa.Column('password', sa.String(length=94), nullable=True),
    sa.Column('role', sa.VARCHAR(length=30), nullable=True),
    sa.ForeignKeyConstraint(['role'], ['role.name'], name=op.f('fk_user_role_role')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_user')),
    sa.UniqueConstraint('username', name=op.f('uq_user_username'))
    )
    op.create_table('group',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('name', sa.VARCHAR(length=30), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_group_user_id_user')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_group'))
    )
    op.create_table('publication',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('name', sa.Text(), nullable=True),
    sa.Column('status', sa.VARCHAR(length=30), nullable=True),
    sa.Column('content', sa.Text(), nullable=True),
    sa.Column('date', sa.Date(), nullable=True),
    sa.ForeignKeyConstraint(['status'], ['publication_status.name'], name=op.f('fk_publication_status_publication_status')),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_publication_user_id_user')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_publication'))
    )
    op.create_table('task',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('max_mark', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_task_user_id_user')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_task'))
    )
    op.create_table('group_student',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('group_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['group_id'], ['group.id'], name=op.f('fk_group_student_group_id_group')),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_group_student_user_id_user')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_group_student'))
    )
    op.create_table('publication_permission_group',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('publication_id', sa.Integer(), nullable=True),
    sa.Column('group_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['group_id'], ['group.id'], name=op.f('fk_publication_permission_group_group_id_group')),
    sa.ForeignKeyConstraint(['publication_id'], ['publication.id'], name=op.f('fk_publication_permission_group_publication_id_publication')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_publication_permission_group'))
    )
    op.create_table('publication_permission_student',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('publication_id', sa.Integer(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['publication_id'], ['publication.id'], name=op.f('fk_publication_permission_student_publication_id_publication')),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_publication_permission_student_user_id_user')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_publication_permission_student'))
    )
    op.create_table('question',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('task_id', sa.Integer(), nullable=True),
    sa.Column('number', sa.Integer(), nullable=True),
    sa.Column('question', sa.Text(), nullable=True),
    sa.Column('correct_answer', sa.Text(), nullable=True),
    sa.Column('type', sa.VARCHAR(length=30), nullable=True),
    sa.Column('max_mark', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['task_id'], ['task.id'], name=op.f('fk_question_task_id_task')),
    sa.ForeignKeyConstraint(['type'], ['question_type.name'], name=op.f('fk_question_type_question_type')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_question'))
    )
    op.create_table('rating_fields',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('task_id', sa.Integer(), nullable=True),
    sa.Column('group_id', sa.Integer(), nullable=True),
    sa.Column('field_name', sa.VARCHAR(length=30), nullable=True),
    sa.Column('required', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['group_id'], ['group.id'], name=op.f('fk_rating_fields_group_id_group')),
    sa.ForeignKeyConstraint(['task_id'], ['task.id'], name=op.f('fk_rating_fields_task_id_task')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_rating_fields'))
    )
    op.create_table('answers',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('question_id', sa.Integer(), nullable=True),
    sa.Column('answer', sa.Text(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['question_id'], ['question.id'], name=op.f('fk_answers_question_id_question')),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_answers_user_id_user')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_answers'))
    )
    op.create_table('rating_list',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.Column('field_id', sa.Integer(), nullable=True),
    sa.Column('mark', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['field_id'], ['rating_fields.id'], name=op.f('fk_rating_list_field_id_rating_fields')),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('fk_rating_list_user_id_user')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_rating_list'))
    )
    op.create_table('tests',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('question_id', sa.Integer(), nullable=True),
    sa.Column('answer', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['question_id'], ['question.id'], name=op.f('fk_tests_question_id_question')),
    sa.PrimaryKeyConstraint('id', name=op.f('pk_tests'))
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('tests')
    op.drop_table('rating_list')
    op.drop_table('answers')
    op.drop_table('rating_fields')
    op.drop_table('question')
    op.drop_table('publication_permission_student')
    op.drop_table('publication_permission_group')
    op.drop_table('group_student')
    op.drop_table('task')
    op.drop_table('publication')
    op.drop_table('group')
    op.drop_table('user')
    op.drop_table('role')
    op.drop_table('question_type')
    op.drop_table('publication_status')
    # ### end Alembic commands ###
