"""add instructions to assistant

Revision ID: 890659c554b6
Revises:
Create Date: 2026-02-02 11:57:09.999851

"""

from collections.abc import Sequence

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "890659c554b6"
down_revision: str | Sequence[str] | None = None
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column("assistant", sa.Column("instructions", sa.Text(), nullable=True))
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("assistant", "instructions")
    op.create_table(
        "llmmodel",
        sa.Column("id", sa.INTEGER(), nullable=False),
        sa.Column("model_name", sa.VARCHAR(), nullable=False),
        sa.Column("display_name", sa.VARCHAR(), nullable=False),
        sa.Column("context_length", sa.INTEGER(), nullable=False),
        sa.Column("model_type", sa.VARCHAR(length=10), nullable=False),
        sa.Column("is_default", sa.BOOLEAN(), nullable=False),
        sa.Column("provider_id", sa.INTEGER(), nullable=False),
        sa.ForeignKeyConstraint(
            ["provider_id"],
            ["llmprovider.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_llmmodel_model_name"), "llmmodel", ["model_name"], unique=False)
    op.create_index(op.f("ix_llmmodel_is_default"), "llmmodel", ["is_default"], unique=False)
    op.create_table(
        "llmprovider",
        sa.Column("id", sa.INTEGER(), nullable=False),
        sa.Column("name", sa.VARCHAR(), nullable=False),
        sa.Column("display_name", sa.VARCHAR(), nullable=False),
        sa.Column("api_base_url", sa.VARCHAR(), nullable=False),
        sa.Column("documentation_url", sa.VARCHAR(), nullable=True),
        sa.Column("requires_api_key", sa.BOOLEAN(), nullable=False),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_llmprovider_name"), "llmprovider", ["name"], unique=1)
    op.create_table(
        "userprovidercredential",
        sa.Column("id", sa.INTEGER(), nullable=False),
        sa.Column("encrypted_api_key", sa.BLOB(), nullable=True),
        sa.Column("user_id", sa.CHAR(length=32), nullable=False),
        sa.Column("provider_id", sa.INTEGER(), nullable=False),
        sa.ForeignKeyConstraint(
            ["provider_id"],
            ["llmprovider.id"],
        ),
        sa.ForeignKeyConstraint(
            ["user_id"],
            ["user.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    # ### end Alembic commands ###
