"""add clip query expression indexes

Revision ID: d936851f725a
Revises: e6f25df0df90
Create Date: 2026-02-13 17:31:01.428765

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'd936851f725a'
down_revision: Union[str, None] = 'e6f25df0df90'
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('idx_clip_states_activity_type', 'clip_states', [sa.literal_column("jsonb_extract_path_text(data, 'analysis_result', 'activity_type')")], unique=False)
    op.create_index('idx_clip_states_alerted', 'clip_states', [sa.literal_column("jsonb_extract_path_text(data, 'alert_decision', 'notify')")], unique=False)
    op.create_index('idx_clip_states_created_at_desc', 'clip_states', [sa.literal_column('created_at DESC')], unique=False)
    op.create_index('idx_clip_states_risk_level', 'clip_states', [sa.literal_column("jsonb_extract_path_text(data, 'analysis_result', 'risk_level')")], unique=False)
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index('idx_clip_states_risk_level', table_name='clip_states')
    op.drop_index('idx_clip_states_created_at_desc', table_name='clip_states')
    op.drop_index('idx_clip_states_alerted', table_name='clip_states')
    op.drop_index('idx_clip_states_activity_type', table_name='clip_states')
    # ### end Alembic commands ###
