"""Remove id_area from hierarchical models

Revision ID: 751a47a06aaa
Revises: ad5a6de3a358
Create Date: 2026-05-18 19:57:18.173726

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '751a47a06aaa'
down_revision: Union[str, None] = 'ad5a6de3a358'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('auxiliares', schema=None) as batch_op:
        batch_op.drop_column('id_area')

    with op.batch_alter_table('colaboradores', schema=None) as batch_op:
        batch_op.drop_column('id_area')

    with op.batch_alter_table('docentes', schema=None) as batch_op:
        batch_op.drop_column('id_area')

    with op.batch_alter_table('servidores', schema=None) as batch_op:
        batch_op.drop_column('id_area')

    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('servidores', schema=None) as batch_op:
        batch_op.add_column(sa.Column('id_area', sa.INTEGER(), autoincrement=False, nullable=True))
        batch_op.create_foreign_key(batch_op.f('servidores_id_area_fkey'), 'areas', ['id_area'], ['id'])
    with op.batch_alter_table('docentes', schema=None) as batch_op:
        batch_op.add_column(sa.Column('id_area', sa.INTEGER(), autoincrement=False, nullable=True))
        batch_op.create_foreign_key(batch_op.f('docentes_id_area_fkey'), 'areas', ['id_area'], ['id'])
    with op.batch_alter_table('colaboradores', schema=None) as batch_op:
        batch_op.add_column(sa.Column('id_area', sa.INTEGER(), autoincrement=False, nullable=True))
        batch_op.create_foreign_key(batch_op.f('colaboradores_id_area_fkey'), 'areas', ['id_area'], ['id'])
    with op.batch_alter_table('auxiliares', schema=None) as batch_op:
        batch_op.add_column(sa.Column('id_area', sa.INTEGER(), autoincrement=False, nullable=True))
        batch_op.create_foreign_key(batch_op.f('auxiliares_id_area_fkey'), 'areas', ['id_area'], ['id'])

    # ### end Alembic commands ###
