"""v0.1.0

Revision ID: 129ac52d0ea0
Revises: e4165ed1da22
Create Date: 2026-02-04 21:53:17.175959

"""
from typing import Sequence, Union

import sqlmodel
from alembic import op
import sqlalchemy as sa

import app

# revision identifiers, used by Alembic.
revision: str = '129ac52d0ea0'
down_revision: Union[str, None] = 'e4165ed1da22'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('llm',
    sa.Column('create_time', sa.DateTime(), nullable=False, comment='Created time'),
    sa.Column('update_time', sa.DateTime(), nullable=False, comment='Updated time'),
    sa.Column('id', app.api.models.base.GUID(), nullable=False),
    sa.Column('provider', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('model_name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('model_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('tags', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('max_tokens', sa.Integer(), nullable=False),
    sa.Column('is_tools', sa.Integer(), server_default=sa.text('-1'), nullable=False),
    sa.Column('status', sa.Integer(), server_default=sa.text('1'), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('provider', 'model_name', name='unique_llm_workspace_provider_model_name')
    )
    op.create_table('workspace_llm',
    sa.Column('create_time', sa.DateTime(), nullable=False, comment='Created time'),
    sa.Column('update_time', sa.DateTime(), nullable=False, comment='Updated time'),
    sa.Column('id', app.api.models.base.GUID(), nullable=False),
    sa.Column('workspace_id', app.api.models.base.GUID(), nullable=False),
    sa.Column('provider', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('model_name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('model_type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
    sa.Column('tags', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
    sa.Column('max_tokens', sa.Integer(), nullable=False),
    sa.Column('is_tools', sa.Integer(), server_default=sa.text('-1'), nullable=False),
    sa.Column('status', sa.Integer(), server_default=sa.text('1'), nullable=False),
    sa.Column('credential_id', app.api.models.base.GUID(), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('workspace_id', 'provider', 'model_name', name='unique_workspace_llm_provider_model_name')
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('workspace_llm')
    op.drop_table('llm')
    # ### end Alembic commands ###
