Files
romm/backend/tests/handler/database
Sam Dornan fb61cbe882 feat(search): Search provider aliases through search_titles and drop generated_search_aliases (#5003)
* Search on search_titles and drop generated_search_aliases

The gallery filter matched provider aliases through a generated column
built from the JSON text, so escaped characters (MariaDB's \uXXXX
storage, tabs, quotes) were out of its reach, and ranking already reads
the folded titles in `search_titles`. Point the MariaDB FULLTEXT index
and the PostgreSQL trigram index at `search_titles` and drop the
generated column. Migration 0147, not yet released, makes the swap; its
downgrade rebuilds 0146's column and index from a frozen copy of their
SQL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6

* Rebuild roms after the search titles backfill on MariaDB

Filling `search_titles` grows every row in place, which leaves InnoDB's
pages split and slowed the FULLTEXT search by 10 to 25 ms on 40,000
ROMs. One table rebuild after a backfill that filled rows restores it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6

* pr-ready code review: describe the alias search test case as it stands

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6

* pr-ready simplify: read the legacy column name off the 0147 migration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6

* pr-ready review-polish: describe the rebuild as the code does it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6

* Freeze 0147's provider list and always rebuild roms on MariaDB

- The backfill and the downgrade's copy of 0146's column read a frozen
  provider list instead of `ALTERNATIVE_NAME_SOURCES`, so a later provider
  can't change what this revision selects or rebuilds.
- The table rebuild runs on every MariaDB/MySQL upgrade: a run that stopped
  after the fill but before the rebuild left nothing to fill on retry.
- Two comments describe why, not what the migration replaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6

* Fold 0146 and 0147 into one search titles revision

Neither revision has shipped, so `0146_roms_search_titles` takes the
roms table from 0145 straight to `search_titles` and its search index,
and `generated_search_aliases` never exists. The search indexes are
dropped first, so the column is added and filled with no index to
maintain, and the index is built once over the filled rows.

Databases on a nightly that ran either old revision need resetting to
0145 before upgrading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6

* Keep the search titles migration under 0146's revision ID

The folded revision now rewrites 0146_roms_search_aliases in place
rather than adding a new ID. A nightly database that already ran the
old 0146 or 0147 still needs resetting to 0145 before upgrading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6

* Say why 0146 adds search_titles ahead of ensure_roms_columns

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015iCApu4gYrGBWDX8JD9JH6

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 22:01:40 -04:00
..
2025-10-23 11:12:17 -04:00