"""empty message

Revision ID: 250dd92bca01
Revises: 0027a39ae0a5
Create Date: 2021-06-10 12:15:24.776166

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '250dd92bca01'
down_revision = '0027a39ae0a5'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('admin',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('lastname', sa.String(length=64), nullable=True),
    sa.Column('username', sa.String(length=64), nullable=True),
    sa.Column('empresa', sa.String(length=100), nullable=True),
    sa.Column('email', sa.String(length=120), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_admin_email'), 'admin', ['email'], unique=True)
    op.create_index(op.f('ix_admin_username'), 'admin', ['username'], unique=True)
    op.add_column('consultas', sa.Column('empresa_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'consultas', 'admin', ['empresa_id'], ['id'])
    op.add_column('user', sa.Column('name', sa.String(length=64), nullable=True))
    op.add_column('user', sa.Column('lastname', sa.String(length=64), nullable=True))
    op.add_column('user', sa.Column('empresa_id', sa.Integer(), nullable=True))
    op.drop_index('ix_user_empresa', table_name='user')
    op.create_foreign_key(None, 'user', 'admin', ['empresa_id'], ['id'])
    op.drop_column('user', 'empresa')
    op.drop_column('user', 'last_seen')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('user', sa.Column('last_seen', sa.DATETIME(), nullable=True))
    op.add_column('user', sa.Column('empresa', sa.VARCHAR(length=64), nullable=True))
    op.drop_constraint(None, 'user', type_='foreignkey')
    op.create_index('ix_user_empresa', 'user', ['empresa'], unique=False)
    op.drop_column('user', 'empresa_id')
    op.drop_column('user', 'lastname')
    op.drop_column('user', 'name')
    op.drop_constraint(None, 'consultas', type_='foreignkey')
    op.drop_column('consultas', 'empresa_id')
    op.drop_index(op.f('ix_admin_username'), table_name='admin')
    op.drop_index(op.f('ix_admin_email'), table_name='admin')
    op.drop_table('admin')
    # ### end Alembic commands ###
