"""empty message

Revision ID: c3e1fba98b39
Revises: a9cf4f05f7c6
Create Date: 2021-06-10 21:50:46.798399

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'c3e1fba98b39'
down_revision = 'a9cf4f05f7c6'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('empresa', schema=None) as batch_op:
        batch_op.add_column(sa.Column('id', sa.Integer(), nullable=False))
        batch_op.add_column(sa.Column('name', sa.String(length=120), nullable=True))
        batch_op.drop_index('ix_empresa_index')
        batch_op.create_unique_constraint(batch_op.f('uq_empresa_rut'), ['rut'])
        batch_op.drop_column('tramoventas')
        batch_op.drop_column('inicio')
        batch_op.drop_column('comuna')
        batch_op.drop_column('trabajadores')
        batch_op.drop_column('index')
        batch_op.drop_column('rubro')

    with op.batch_alter_table('sii', schema=None) as batch_op:
        batch_op.alter_column('rut',
               existing_type=sa.TEXT(),
               nullable=False)
        batch_op.drop_index('ix_sii_index')
        batch_op.drop_column('index')

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('sii', schema=None) as batch_op:
        batch_op.add_column(sa.Column('index', sa.INTEGER(), nullable=True))
        batch_op.create_index('ix_sii_index', ['index'], unique=False)
        batch_op.alter_column('rut',
               existing_type=sa.TEXT(),
               nullable=True)

    with op.batch_alter_table('empresa', schema=None) as batch_op:
        batch_op.add_column(sa.Column('rubro', sa.TEXT(), nullable=True))
        batch_op.add_column(sa.Column('index', sa.INTEGER(), nullable=True))
        batch_op.add_column(sa.Column('trabajadores', sa.INTEGER(), nullable=True))
        batch_op.add_column(sa.Column('comuna', sa.TEXT(), nullable=True))
        batch_op.add_column(sa.Column('inicio', sa.TEXT(), nullable=True))
        batch_op.add_column(sa.Column('tramoventas', sa.INTEGER(), nullable=True))
        batch_op.drop_constraint(batch_op.f('uq_empresa_rut'), type_='unique')
        batch_op.create_index('ix_empresa_index', ['index'], unique=False)
        batch_op.drop_column('name')
        batch_op.drop_column('id')

    # ### end Alembic commands ###
