"""add_max_images_to_llm_providers

Revision ID: ed28d34edde7
Revises: 7703bbc038bd
Create Date: 2026-05-31 22:19:21.922928

"""

from typing import Sequence, Union

from alembic import op
from sqlalchemy import inspect
import sqlalchemy as sa


revision: str = 'ed28d34edde7'
down_revision: Union[str, Sequence[str], None] = '7703bbc038bd'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # The llm_providers table is defined in the ORM model and created by
    # Base.metadata.create_all() at app startup, not via migrations.
    # If the table doesn't exist yet (fresh DB), skip — the model definition
    # already includes max_images, so create_all() will create it with the column.
    conn = op.get_bind()
    inspector = inspect(conn)
    if "llm_providers" not in inspector.get_table_names():
        return
    op.add_column('llm_providers', sa.Column('max_images', sa.Integer(), nullable=True))


def downgrade() -> None:
    op.drop_column('llm_providers', 'max_images')
