"""Keep user_id only on inferences table.

Revision ID: 234b9fdee6c2
Revises: 8dd0c9ed869c
Create Date: 2024-05-29 10:00:38.383429

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "234b9fdee6c2"
down_revision = "8dd0c9ed869c"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column("inferences", sa.Column("user_id", sa.String(), nullable=True))
    op.alter_column(
        "prompt_rule_results",
        "latency_ms",
        existing_type=sa.INTEGER(),
        nullable=False,
    )
    op.alter_column(
        "response_rule_results",
        "latency_ms",
        existing_type=sa.INTEGER(),
        nullable=False,
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "response_rule_results",
        "latency_ms",
        existing_type=sa.INTEGER(),
        nullable=True,
    )
    op.alter_column(
        "prompt_rule_results",
        "latency_ms",
        existing_type=sa.INTEGER(),
        nullable=True,
    )
    op.drop_column("inferences", "user_id")
    # ### end Alembic commands ###
