"""empty message

Revision ID: a29d11947ea5
Revises: 
Create Date: 2021-01-29 00:28:59.965588

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
from api.database.triggers import *

# revision identifiers, used by Alembic.
revision = 'a29d11947ea5'
down_revision = None
branch_labels = None
depends_on = None
connection = op.get_bind()


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_sequence("Employee_seq_autoid")
    op.create_sequence("Employee_id_autoid")
    op.create_table('Employee',
    sa.Column('id', sa.Integer(), server_default=sa.text("nextval('employee_id_autoid')"), nullable=False),
    sa.Column('employeeId', sa.VARCHAR(length=25), nullable=False),
    sa.Column('firstName', sa.VARCHAR(length=200), nullable=True),
    sa.Column('lastName', sa.VARCHAR(length=200), nullable=True),
    sa.Column('password', sa.VARCHAR(length=500), nullable=True),
    sa.Column('email', sa.VARCHAR(length=200), nullable=False),
    sa.Column('phoneNumber', sa.VARCHAR(length=20), nullable=True),
    sa.Column('joinedDate', sa.TIMESTAMP(), nullable=True),
    sa.Column('employeeType', postgresql.ENUM('EMPLOYEE', 'ADMIN', name='EmployeeTYPE'), server_default='EMPLOYEE', nullable=False),
    sa.Column('employeeDesignation', postgresql.ENUM('DEVELOPER', 'SENIOR DEVELOPER', 'MANAGER', name='EmployeeDESIGNATION'), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('employeeId')
    )
    op.create_sequence("Holiday_id_autoid")
    op.create_table('Holiday',
    sa.Column('id', sa.Integer(), server_default=sa.text("nextval('holiday_id_autoid')"), nullable=False),
    sa.Column('date', sa.TIMESTAMP(), nullable=True),
    sa.Column('festivalName', sa.VARCHAR(length=200), nullable=True),
    sa.Column('description', sa.VARCHAR(length=500), nullable=True),
    sa.Column('holidayBanner', sa.VARCHAR(length=8000), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_sequence("LeaveManagement_seq_autoid")
    op.create_sequence("LeaveManagement_id_autoid")
    op.create_table('LeaveManagement',
    sa.Column('id', sa.Integer(), server_default=sa.text('nextval(\'"leavemanagement_id_autoid"\')'), nullable=False),
    sa.Column('leaveId', sa.VARCHAR(length=25), nullable=False),
    sa.Column('employeeId', sa.VARCHAR(length=25), nullable=False),
    sa.Column('fromDate', sa.TIMESTAMP(), nullable=True),
    sa.Column('toDate', sa.TIMESTAMP(), nullable=True),
    sa.Column('reason', sa.VARCHAR(length=500), nullable=False),
    sa.Column('leaveType', postgresql.ENUM('SICK', 'MEDICAL', 'CASUAL', name='LeaveTYPE'), nullable=False),
    sa.Column('approver', sa.VARCHAR(length=200), nullable=True),
    sa.Column('approvedStatus', postgresql.ENUM('PENDING', 'ACCEPTED', 'DENIED', name='ApprovedSTATUS'), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('leaveId')
    )
    op.create_sp(Employees_trigger)
    op.create_sp(Leave_trigger)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('LeaveManagement')
    op.drop_sequence("LeaveManagement_seq_autoid")
    op.drop_sequence("LeaveManagement_id_autoid")
    op.drop_table('Holiday')
    op.drop_table('Employee')
    op.drop_sequence("Holiday_id_autoid")
    op.drop_sequence("Employee_id_autoid")
    op.drop_sequence("Employee_seq_autoid")
    op.drop_sp(Leave_trigger)
    op.drop_sp(Employees_trigger)
    sa.Enum(name='ApprovedSTATUS').drop(op.get_bind(), checkfirst=False)
    sa.Enum(name='LeaveTYPE').drop(op.get_bind(), checkfirst=False)
    sa.Enum(name='EmployeeDESIGNATION').drop(op.get_bind(), checkfirst=False)
    sa.Enum(name='EmployeeTYPE').drop(op.get_bind(), checkfirst=False)
    # ### end Alembic commands ###
