"""added llm_tool_name

Revision ID: 667874dd7dee
Revises: c98f44cea12f
Create Date: 2025-06-17 13:53:18.588902

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '667874dd7dee'
down_revision = 'c98f44cea12f'
branch_labels = None
depends_on = None


def upgrade():
    op.add_column('tool', sa.Column('alias', sa.String(), nullable=True))
    op.execute("""
        UPDATE tool
        SET alias = tool.name || '__' || server.name
        FROM server
        WHERE server.url = tool.server_url;
    """)
    op.alter_column("tool", "alias", nullable=False)

def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('tool', 'alias')
    # ### end Alembic commands ###
