"""add_gin_index_on_agent_card_tags

Revision ID: ed219e8077fc
Revises: 495a40fce45f
Create Date: 2025-04-14 20:47:35.281777

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
# --- ADDED: Import postgresql dialect for type hint consistency ---
from sqlalchemy.dialects import postgresql
# --- END ADDED ---


# revision identifiers, used by Alembic.
revision: str = 'ed219e8077fc'
# --- MODIFIED: Point down_revision to the column type change migration ---
down_revision: Union[str, None] = '495a40fce45f'
# --- END MODIFIED ---
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_agent_cards_card_data_tags_gin',      # Index name
        'agent_cards',                            # Table name
        ['card_data'],                            # Column to index
        unique=False,
        postgresql_using='gin',                   # Specify GIN index type
        postgresql_ops={'card_data': 'jsonb_path_ops'} # Use jsonb_path_ops for efficient path/containment queries
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(
        'ix_agent_cards_card_data_tags_gin',      # Index name
        table_name='agent_cards',                 # Table name
        postgresql_using='gin'                    # Specify index type for dropping if needed by dialect
    )
    # ### end Alembic commands ###
