"""Migration-reinitdb

Revision ID: 7b098aa43e03
Revises: ccc27d477004
Create Date: 2020-12-13 21:26:37.400991

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

# revision identifiers, used by Alembic.
revision = '7b098aa43e03'
down_revision = 'ccc27d477004'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('candidates',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('email', sa.String(length=255), nullable=False),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('phone', sa.String(length=15), nullable=True),
    sa.Column('full_name', sa.String(length=80), nullable=True),
    sa.Column('gender', sa.Boolean(), nullable=False),
    sa.Column('date_of_birth', sa.DateTime(), nullable=True),
    sa.Column('status', sa.Integer(), nullable=True),
    sa.Column('access_token', sa.String(length=512), nullable=True),
    sa.Column('registered_on', sa.DateTime(), nullable=False),
    sa.Column('confirmed', sa.Boolean(), nullable=False),
    sa.Column('confirmed_on', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )
    op.create_table('companies',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('name', sa.String(length=80), nullable=True),
    sa.Column('acronym', sa.String(length=80), nullable=True),
    sa.Column('location', sa.String(length=180), nullable=True),
    sa.Column('phone', sa.String(length=15), nullable=True),
    sa.Column('email', sa.String(length=255), nullable=True),
    sa.Column('logo', sa.String(length=255), nullable=True),
    sa.Column('website', sa.String(length=255), nullable=True),
    sa.Column('description', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('recruiters',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('email', sa.String(length=255), nullable=False),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('phone', sa.String(length=15), nullable=True),
    sa.Column('full_name', sa.String(length=80), nullable=True),
    sa.Column('gender', sa.Boolean(), nullable=False),
    sa.Column('status', sa.Integer(), nullable=True),
    sa.Column('company_id', sa.Integer(), nullable=True),
    sa.Column('access_token', sa.String(length=512), nullable=True),
    sa.Column('registered_on', sa.DateTime(), nullable=False),
    sa.Column('confirmed', sa.Boolean(), nullable=False),
    sa.Column('confirmed_on', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['company_id'], ['companies.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('company_id'),
    sa.UniqueConstraint('email')
    )
    op.drop_table('recruiter')
    op.drop_table('company')
    op.drop_table('candidate')
    op.drop_table('account')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('candidate',
    sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
    sa.Column('account_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.Column('date_of_birth', mysql.DATETIME(), nullable=True),
    sa.ForeignKeyConstraint(['account_id'], ['account.id'], name='candidate_ibfk_1'),
    sa.PrimaryKeyConstraint('id'),
    mysql_collate='utf8_unicode_ci',
    mysql_default_charset='utf8',
    mysql_engine='InnoDB'
    )
    op.create_index('account_id', 'candidate', ['account_id'], unique=True)
    op.create_table('account',
    sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
    sa.Column('email', mysql.VARCHAR(collation='utf8_unicode_ci', length=255), nullable=False),
    sa.Column('password_hash', mysql.VARCHAR(collation='utf8_unicode_ci', length=128), nullable=True),
    sa.Column('phone', mysql.VARCHAR(collation='utf8_unicode_ci', length=15), nullable=True),
    sa.Column('full_name', mysql.VARCHAR(collation='utf8_unicode_ci', length=80), nullable=True),
    sa.Column('gender', mysql.TINYINT(display_width=1), autoincrement=False, nullable=False),
    sa.Column('access_token', mysql.VARCHAR(collation='utf8_unicode_ci', length=512), nullable=True),
    sa.Column('registered_on', mysql.DATETIME(), nullable=False),
    sa.Column('confirmed', mysql.TINYINT(display_width=1), autoincrement=False, nullable=False),
    sa.Column('confirmed_on', mysql.DATETIME(), nullable=True),
    sa.CheckConstraint('`confirmed` in (0,1)', name='CONSTRAINT_2'),
    sa.CheckConstraint('`gender` in (0,1)', name='CONSTRAINT_1'),
    sa.PrimaryKeyConstraint('id'),
    mysql_collate='utf8_unicode_ci',
    mysql_default_charset='utf8',
    mysql_engine='InnoDB'
    )
    op.create_index('email', 'account', ['email'], unique=True)
    op.create_table('company',
    sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
    sa.Column('name', mysql.VARCHAR(collation='utf8_unicode_ci', length=80), nullable=True),
    sa.Column('location', mysql.VARCHAR(collation='utf8_unicode_ci', length=180), nullable=True),
    sa.Column('phone', mysql.VARCHAR(collation='utf8_unicode_ci', length=15), nullable=True),
    sa.Column('email', mysql.VARCHAR(collation='utf8_unicode_ci', length=255), nullable=True),
    sa.Column('logo', mysql.VARCHAR(collation='utf8_unicode_ci', length=255), nullable=True),
    sa.Column('website', mysql.VARCHAR(collation='utf8_unicode_ci', length=255), nullable=True),
    sa.Column('description', mysql.VARCHAR(collation='utf8_unicode_ci', length=255), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    mysql_collate='utf8_unicode_ci',
    mysql_default_charset='utf8',
    mysql_engine='InnoDB'
    )
    op.create_table('recruiter',
    sa.Column('id', mysql.INTEGER(display_width=11), autoincrement=True, nullable=False),
    sa.Column('account_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.Column('company_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['account_id'], ['account.id'], name='recruiter_ibfk_1'),
    sa.ForeignKeyConstraint(['company_id'], ['company.id'], name='recruiter_ibfk_2'),
    sa.PrimaryKeyConstraint('id'),
    mysql_collate='utf8_unicode_ci',
    mysql_default_charset='utf8',
    mysql_engine='InnoDB'
    )
    op.create_index('company_id', 'recruiter', ['company_id'], unique=True)
    op.create_index('account_id', 'recruiter', ['account_id'], unique=True)
    op.drop_table('recruiters')
    op.drop_table('companies')
    op.drop_table('candidates')
    # ### end Alembic commands ###
