"""partial index for artifacts table

Revision ID: 08f585f2e7a6
Revises: a86c9fdba6b3
Create Date: 2026-03-06 18:04:47.414053+00:00

"""

from typing import Sequence, Union

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "08f585f2e7a6"
down_revision: Union[str, None] = "a86c9fdba6b3"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_index(
        "ix_artifacts_observer_cruise_id_partial",
        "artifacts",
        ["observer_cruise_id"],
        unique=False,
        postgresql_where=sa.text("observer_cruise_id IS NOT NULL"),
    )
    op.create_index(
        "ix_artifacts_observer_thought_id_partial",
        "artifacts",
        ["observer_thought_id"],
        unique=False,
        postgresql_where=sa.text("observer_thought_id IS NOT NULL"),
    )
    op.create_index(
        "ix_artifacts_run_id_partial",
        "artifacts",
        ["run_id"],
        unique=False,
        postgresql_where=sa.text("run_id IS NOT NULL"),
    )
    op.create_index(
        "ix_artifacts_workflow_run_block_id_partial",
        "artifacts",
        ["workflow_run_block_id"],
        unique=False,
        postgresql_where=sa.text("workflow_run_block_id IS NOT NULL"),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(
        "ix_artifacts_workflow_run_block_id_partial",
        table_name="artifacts",
        postgresql_where=sa.text("workflow_run_block_id IS NOT NULL"),
    )
    op.drop_index("ix_artifacts_run_id_partial", table_name="artifacts", postgresql_where=sa.text("run_id IS NOT NULL"))
    op.drop_index(
        "ix_artifacts_observer_thought_id_partial",
        table_name="artifacts",
        postgresql_where=sa.text("observer_thought_id IS NOT NULL"),
    )
    op.drop_index(
        "ix_artifacts_observer_cruise_id_partial",
        table_name="artifacts",
        postgresql_where=sa.text("observer_cruise_id IS NOT NULL"),
    )
    # ### end Alembic commands ###
