"""Add new database tables for prompt and response data

Revision ID: bf46ba93762f
Revises: e04161e97672
Create Date: 2023-06-27 09:04:04.886311

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "bf46ba93762f"
down_revision = "e04161e97672"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "inference_prompt_contents",
        sa.Column("inference_prompt_id", sa.String(), nullable=False),
        sa.Column("content", sa.String(), nullable=False),
        sa.ForeignKeyConstraint(
            ["inference_prompt_id"],
            ["inference_prompts.id"],
        ),
        sa.PrimaryKeyConstraint("inference_prompt_id"),
        sa.UniqueConstraint("inference_prompt_id"),
    )
    op.create_index(
        op.f("ix_inference_prompt_contents_inference_prompt_id"),
        "inference_prompt_contents",
        ["inference_prompt_id"],
        unique=False,
    )
    op.create_table(
        "inference_response_contents",
        sa.Column("inference_response_id", sa.String(), nullable=False),
        sa.Column("content", sa.String(), nullable=False),
        sa.ForeignKeyConstraint(
            ["inference_response_id"],
            ["inference_responses.id"],
        ),
        sa.PrimaryKeyConstraint("inference_response_id"),
        sa.UniqueConstraint("inference_response_id"),
    )
    op.create_index(
        op.f("ix_inference_response_contents_inference_response_id"),
        "inference_response_contents",
        ["inference_response_id"],
        unique=False,
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(
        op.f("ix_inference_response_contents_inference_response_id"),
        table_name="inference_response_contents",
    )
    op.drop_table("inference_response_contents")
    op.drop_index(
        op.f("ix_inference_prompt_contents_inference_prompt_id"),
        table_name="inference_prompt_contents",
    )
    op.drop_table("inference_prompt_contents")
    # ### end Alembic commands ###
