"""Add embeddings reference table

Revision ID: 3759d5136235
Revises: ac244fdc928b
Create Date: 2023-10-05 09:36:03.281537

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "3759d5136235"
down_revision = "ac244fdc928b"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "inference_embeddings",
        sa.Column("id", sa.String(), nullable=False),
        sa.Column("inference_id", sa.String(), nullable=False),
        sa.Column("embedding_id", sa.String(), nullable=False),
        sa.ForeignKeyConstraint(
            ["embedding_id"],
            ["embeddings.id"],
        ),
        sa.ForeignKeyConstraint(
            ["inference_id"],
            ["inferences.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(
        op.f("ix_inference_embeddings_id"),
        "inference_embeddings",
        ["id"],
        unique=False,
    )
    op.create_index(
        op.f("ix_inference_embeddings_inference_id"),
        "inference_embeddings",
        ["inference_id"],
        unique=False,
    )
    # ### end Alembic commands ###


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