"""add_name_column_to_llm_connections

Revision ID: 2fc672af4630
Revises: 0e360e93a0d9
Create Date: 2025-10-14 01:33:40.825826

"""

from alembic import op
import sqlalchemy as sa



# revision identifiers, used by Alembic.
revision = '2fc672af4630'
down_revision = '0e360e93a0d9'
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    # Check if column exists before adding it (handles case where it was manually added)
    conn = op.get_bind()
    inspector = sa.inspect(conn)
    columns = [col['name'] for col in inspector.get_columns('llm_connections')]

    if 'name' not in columns:
        op.add_column('llm_connections', sa.Column('name', sa.Text(), nullable=True))
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('llm_connections', 'name')
    # ### end Alembic commands ###

