"""create rag configs

Revision ID: 5a02e38003af
Revises: 16d81eaac5c2
Create Date: 2025-10-30 12:09:52.294798

"""

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "5a02e38003af"
down_revision = "16d81eaac5c2"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "rag_provider_configurations",
        sa.Column("id", sa.UUID(), nullable=False),
        sa.Column("authentication_method", sa.String(), nullable=False),
        sa.Column("task_id", sa.String(), nullable=False),
        sa.Column("name", sa.String(), nullable=False),
        sa.Column("description", sa.String(), nullable=True),
        sa.Column("created_at", sa.TIMESTAMP(), nullable=False),
        sa.Column("updated_at", sa.TIMESTAMP(), nullable=False),
        sa.Column("api_key_secret_id", sa.String(), nullable=True),
        sa.Column("host_url", sa.String(), nullable=True),
        sa.Column("rag_provider", sa.String(), nullable=True),
        sa.ForeignKeyConstraint(
            ["api_key_secret_id"],
            ["secret_storage.id"],
        ),
        sa.ForeignKeyConstraint(
            ["task_id"],
            ["tasks.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_rag_provider_configurations_api_key_secret_id"),
        "rag_provider_configurations",
        ["api_key_secret_id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_rag_provider_configurations_task_id"),
        "rag_provider_configurations",
        ["task_id"],
        unique=False,
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(
        op.f("ix_rag_provider_configurations_task_id"),
        table_name="rag_provider_configurations",
    )
    op.drop_index(
        op.f("ix_rag_provider_configurations_api_key_secret_id"),
        table_name="rag_provider_configurations",
    )
    op.drop_table("rag_provider_configurations")
    # ### end Alembic commands ###
