"""add support for vllm model provider

Revision ID: c2ef79d7a62d
Revises: f18f1870b3d7
Create Date: 2026-01-29 15:11:19.293710

"""

import sqlalchemy as sa

from alembic import op
from db_models.custom_types import EncryptedJSON

# revision identifiers, used by Alembic.
revision = "c2ef79d7a62d"
down_revision = "f18f1870b3d7"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "secret_storage",
        sa.Column("api_base", EncryptedJSON(), nullable=True),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # Remove vllm credentials from secret storage on downgrade since it is unsupported and we would
    # lose the credentials needed to run it if we upgraded again
    op.execute(
        "DELETE FROM secret_storage WHERE secret_type = 'model_provider' AND name = 'hosted_vllm'",
    )

    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("secret_storage", "api_base")
    # ### end Alembic commands ###
