32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
|
|
"""accent-insensitive feed search (unaccent)
|
||
|
|
|
||
|
|
Revision ID: 0029_unaccent_search
|
||
|
|
Revises: 0028_live_search_provenance
|
||
|
|
Create Date: 2026-06-29
|
||
|
|
|
||
|
|
Enables the PostgreSQL `unaccent` contrib extension so the feed's text search can match
|
||
|
|
regardless of diacritics — e.g. searching "tiesto" finds titles spelled "Tiësto". The feed
|
||
|
|
query wraps both sides in unaccent(); this migration just makes the function available.
|
||
|
|
`unaccent` ships with the official postgres image (postgresql-contrib). The DB role is a
|
||
|
|
superuser in our deployments, so CREATE EXTENSION succeeds; IF NOT EXISTS keeps it idempotent.
|
||
|
|
"""
|
||
|
|
from typing import Sequence, Union
|
||
|
|
|
||
|
|
from alembic import op
|
||
|
|
|
||
|
|
revision: str = "0029_unaccent_search"
|
||
|
|
down_revision: Union[str, None] = "0028_live_search_provenance"
|
||
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
||
|
|
depends_on: Union[str, Sequence[str], None] = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
op.execute("CREATE EXTENSION IF NOT EXISTS unaccent")
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
# Intentionally left in place: other code/queries may rely on unaccent() and dropping a
|
||
|
|
# contrib extension is rarely what's wanted on a downgrade. (The feed query reverts with
|
||
|
|
# the code, not this migration.)
|
||
|
|
pass
|