"""add index to history models

Revision ID: 40d6d6511b20
Revises: 7673fe18c05d
Create Date: 2025-11-14 10:34:12.300920

"""

from alembic import op

# revision identifiers, used by Alembic.
revision = "40d6d6511b20"
down_revision = "7673fe18c05d"
branch_labels = None
depends_on = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("historyimagecache", schema=None) as batch_op:
        batch_op.create_index(
            batch_op.f("ix_historyimagecache_latest_history_unit_id"),
            ["latest_history_unit_id"],
            unique=False,
        )

    with op.batch_alter_table("historyunit", schema=None) as batch_op:
        batch_op.create_index(
            batch_op.f("ix_historyunit_history_run_id"),
            ["history_run_id"],
            unique=False,
        )

    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table("historyunit", schema=None) as batch_op:
        batch_op.drop_index(batch_op.f("ix_historyunit_history_run_id"))

    with op.batch_alter_table("historyimagecache", schema=None) as batch_op:
        batch_op.drop_index(
            batch_op.f("ix_historyimagecache_latest_history_unit_id")
        )

    # ### end Alembic commands ###
