"""Update clients table for new fields

Revision ID: 207f5b190f93
Revises: 3d15c3cac7b6
Create Date: 2025-07-15 14:12:42.427274

"""
from typing import Sequence, Union

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

# revision identifiers, used by Alembic.
revision: str = '207f5b190f93'
down_revision: Union[str, None] = '3d15c3cac7b6'
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.add_column('clients', sa.Column('hardware_token', sa.String(length=64), nullable=True))
    op.add_column('clients', sa.Column('ip', sa.String(length=45), nullable=True))
    op.add_column('clients', sa.Column('type', sa.String(length=50), nullable=True))
    op.add_column('clients', sa.Column('hostname', sa.String(length=100), nullable=True))
    op.add_column('clients', sa.Column('os_version', sa.String(length=100), nullable=True))
    op.add_column('clients', sa.Column('software_version', sa.String(length=100), nullable=True))
    op.add_column('clients', sa.Column('macs', sa.String(length=255), nullable=True))
    op.add_column('clients', sa.Column('model', sa.String(length=100), nullable=True))
    op.drop_index(op.f('ix_clients_hardware_hash'), table_name='clients')
    op.drop_index(op.f('ix_clients_ip_address'), table_name='clients')
    op.drop_column('clients', 'location')
    op.drop_column('clients', 'hardware_hash')
    op.drop_column('clients', 'ip_address')
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('clients', sa.Column('ip_address', mysql.VARCHAR(length=45), nullable=True))
    op.add_column('clients', sa.Column('hardware_hash', mysql.VARCHAR(length=64), nullable=False))
    op.add_column('clients', sa.Column('location', mysql.VARCHAR(length=100), nullable=True))
    op.create_index(op.f('ix_clients_ip_address'), 'clients', ['ip_address'], unique=False)
    op.create_index(op.f('ix_clients_hardware_hash'), 'clients', ['hardware_hash'], unique=False)
    op.drop_column('clients', 'model')
    op.drop_column('clients', 'macs')
    op.drop_column('clients', 'software_version')
    op.drop_column('clients', 'os_version')
    op.drop_column('clients', 'hostname')
    op.drop_column('clients', 'type')
    op.drop_column('clients', 'ip')
    op.drop_column('clients', 'hardware_token')
    # ### end Alembic commands ###
