"""slop firewall seperation

Revision ID: fdcb5aa33b76
Revises: 04398db10434
Create Date: 2025-11-21 17:33:31.778613

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = 'fdcb5aa33b76'
down_revision: Union[str, Sequence[str], None] = '04398db10434'
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! ###
    op.create_table('kea_client_class_defs',
    sa.Column('stack_fqdn', sa.String(length=253), nullable=False),
    sa.Column('class_name', sa.String(length=253), nullable=False),
    sa.Column('class_content', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
    sa.PrimaryKeyConstraint('class_name')
    )

    # manual pkey change
    op.drop_constraint('kea_reservations_pkey', 'kea_reservations', type_='primary')
    op.create_primary_key('kea_reservations_pkey', 'kea_reservations', ['mac'])

    op.add_column('kea_reservations', sa.Column('client_classes', sa.String(length=1000), nullable=True))
    op.alter_column('kea_reservations', 'ip',
               existing_type=postgresql.INET(),
               nullable=True)
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # manual change
    op.drop_constraint('kea_reservations_pkey', 'kea_reservations', type_='primary')
    op.create_primary_key('kea_reservations_pkey', 'kea_reservations', ['ip'])

    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column('kea_reservations', 'ip',
               existing_type=postgresql.INET(),
               nullable=False)
    op.drop_column('kea_reservations', 'client_classes')
    op.drop_table('kea_client_class_defs')
    # ### end Alembic commands ###
