"""sync agent gateway linkage schema

Revision ID: b308f2876359
Revises: a1e6b0d62f0c
Create Date: 2026-02-10 15:49:54.395003

"""
from __future__ import annotations

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'b308f2876359'
down_revision = 'a1e6b0d62f0c'
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('agents', sa.Column('gateway_id', sa.Uuid(), nullable=False))
    op.create_index(op.f('ix_agents_gateway_id'), 'agents', ['gateway_id'], unique=False)
    op.create_foreign_key('fk_agents_gateway_id_gateways', 'agents', 'gateways', ['gateway_id'], ['id'])
    op.drop_column('gateways', 'main_session_key')
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('gateways', sa.Column('main_session_key', sa.VARCHAR(), autoincrement=False, nullable=False))
    op.drop_constraint('fk_agents_gateway_id_gateways', 'agents', type_='foreignkey')
    op.drop_index(op.f('ix_agents_gateway_id'), table_name='agents')
    op.drop_column('agents', 'gateway_id')
    # ### end Alembic commands ###
