"""add_name_column_to_connections

Revision ID: 0e360e93a0d9
Revises: 4e084a86c962
Create Date: 2025-10-06 14:46:15.035810

"""

from alembic import op
import sqlalchemy as sa



# revision identifiers, used by Alembic.
revision = '0e360e93a0d9'
down_revision = '4e084a86c962'
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('connections')]

    if 'name' not in columns:
        op.add_column('connections', sa.Column('name', sa.Text(), nullable=True))

    # Note: Removed alter_column for llm_connections as SQLite doesn't support ALTER COLUMN
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    # Note: Removed alter_column for llm_connections as SQLite doesn't support ALTER COLUMN
    op.drop_column('connections', 'name')
    # ### end Alembic commands ###

