"""init

Revision ID: 4da0df6b49e7
Revises: 
Create Date: 2020-12-04 16:57:54.556807

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

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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('admin_settings',
    sa.Column('semester', sa.VARCHAR(length=255), nullable=False),
    sa.PrimaryKeyConstraint('semester')
    )
    op.create_table('course',
    sa.Column('crn', sa.VARCHAR(length=255), nullable=False),
    sa.Column('section', sa.VARCHAR(length=255), nullable=True),
    sa.Column('semester', sa.VARCHAR(length=255), nullable=True),
    sa.Column('min_credits', sa.INTEGER(), nullable=True),
    sa.Column('max_credits', sa.INTEGER(), nullable=True),
    sa.Column('date_start', sa.DATE(), nullable=True),
    sa.Column('date_end', sa.DATE(), nullable=True),
    sa.Column('department', sa.VARCHAR(length=255), nullable=True),
    sa.Column('level', sa.INTEGER(), nullable=True),
    sa.Column('title', sa.VARCHAR(length=255), nullable=True),
    sa.Column('full_title', sa.TEXT(), nullable=True),
    sa.Column('description', sa.TEXT(), nullable=True),
    sa.Column('raw_precoreqs', sa.TEXT(), nullable=True),
    sa.Column('frequency', sa.VARCHAR(length=255), nullable=True),
    sa.Column('school', sa.VARCHAR(length=255), nullable=True),
    sa.Column('tsv', postgresql.TSVECTOR(), nullable=True),
    sa.PrimaryKeyConstraint('crn')
    )
    op.create_table('course_corequisite',
    sa.Column('department', sa.VARCHAR(length=255), nullable=False),
    sa.Column('level', sa.INTEGER(), nullable=False),
    sa.Column('corequisite', sa.VARCHAR(length=255), nullable=False),
    sa.PrimaryKeyConstraint('department', 'level', 'corequisite')
    )
    op.create_table('course_prerequisite',
    sa.Column('department', sa.VARCHAR(length=255), nullable=False),
    sa.Column('level', sa.INTEGER(), nullable=False),
    sa.Column('prerequisite', sa.VARCHAR(length=255), nullable=False),
    sa.PrimaryKeyConstraint('department', 'level', 'prerequisite')
    )
    op.create_table('course_session',
    sa.Column('crn', sa.VARCHAR(length=255), nullable=False),
    sa.Column('section', sa.VARCHAR(length=255), nullable=False),
    sa.Column('semester', sa.VARCHAR(length=255), nullable=False),
    sa.Column('time_start', postgresql.TIME(), nullable=True),
    sa.Column('time_end', postgresql.TIME(), nullable=True),
    sa.Column('day_of_week', sa.INTEGER(), nullable=False),
    sa.Column('location', sa.VARCHAR(length=255), nullable=True),
    sa.PrimaryKeyConstraint('crn', 'section', 'semester', 'day_of_week')
    )
    op.create_table('event',
    sa.Column('event_id', sa.INTEGER(), nullable=False),
    sa.Column('description', sa.VARCHAR(length=255), nullable=True),
    sa.PrimaryKeyConstraint('event_id')
    )
    op.create_table('semester_date_range',
    sa.Column('semester_part_name', sa.VARCHAR(length=255), nullable=True),
    sa.Column('date_start', sa.DATE(), nullable=False),
    sa.Column('date_end', sa.DATE(), nullable=False),
    sa.PrimaryKeyConstraint('date_start', 'date_end')
    )
    op.create_table('semester_info',
    sa.Column('semester', sa.VARCHAR(length=255), nullable=False),
    sa.Column('public', sa.BOOLEAN(), nullable=True),
    sa.PrimaryKeyConstraint('semester')
    )
    op.create_table('user_account',
    sa.Column('user_id', sa.INTEGER(), nullable=False),
    sa.Column('name', sa.TEXT(), nullable=True),
    sa.Column('email', sa.TEXT(), nullable=False),
    sa.Column('phone', sa.TEXT(), nullable=True),
    sa.Column('password', sa.TEXT(), nullable=True),
    sa.Column('major', sa.TEXT(), nullable=True),
    sa.Column('degree', sa.TEXT(), nullable=True),
    sa.Column('enable', sa.BOOLEAN(), nullable=True),
    sa.Column('admin', sa.BOOLEAN(), nullable=True),
    sa.Column('super_admin', sa.BOOLEAN(), nullable=True),
    sa.PrimaryKeyConstraint('user_id'),
    sa.UniqueConstraint('email')
    )
    op.create_table('user_event',
    sa.Column('event_id', sa.INTEGER(), nullable=False),
    sa.Column('user_id', postgresql.UUID(), nullable=False),
    sa.Column('content', sa.VARCHAR(length=255), nullable=True),
    sa.Column('created_at', sa.BIGINT(), nullable=True),
    sa.PrimaryKeyConstraint('event_id', 'user_id')
    )
    op.create_table('user_session',
    sa.Column('session_id', postgresql.UUID(), nullable=False),
    sa.Column('user_id', sa.INTEGER(), nullable=False),
    sa.Column('start_time', postgresql.TIMESTAMP(timezone=True), nullable=True),
    sa.Column('end_time', postgresql.TIMESTAMP(timezone=True), nullable=True),
    sa.PrimaryKeyConstraint('session_id')
    )
    op.create_table('student_course_selection',
    sa.Column('user_id', sa.INTEGER(), nullable=False),
    sa.Column('semester', sa.VARCHAR(length=255), nullable=False),
    sa.Column('course_name', sa.VARCHAR(length=255), nullable=False),
    sa.Column('crn', sa.VARCHAR(length=255), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['user_account.user_id'], ),
    sa.PrimaryKeyConstraint('user_id', 'semester', 'course_name', 'crn')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('student_course_selection')
    op.drop_table('user_session')
    op.drop_table('user_event')
    op.drop_table('user_account')
    op.drop_table('semester_info')
    op.drop_table('semester_date_range')
    op.drop_table('event')
    op.drop_table('course_session')
    op.drop_table('course_prerequisite')
    op.drop_table('course_corequisite')
    op.drop_table('course')
    op.drop_table('admin_settings')
    # ### end Alembic commands ###
