"""rebuild search_tsv gin index

Revision ID: 0314f4d28728
Revises: e341edea85e2
Create Date: 2026-07-10 19:04:36.208923
"""
from typing import Sequence, Union

from alembic import op

revision: str = '0314f4d28728'
down_revision: Union[str, None] = 'e341edea85e2'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # 重建 GIN 索引（曾被 f80dca5baa02 upgrade() 误 drop 未重建）
    op.create_index(
        'ix_gl_search_tsv',
        'global_literature',
        ['search_tsv'],
        postgresql_using='gin',
    )


def downgrade() -> None:
    op.drop_index('ix_gl_search_tsv', table_name='global_literature')
