Repository navigation
Catalog search schema: library_track_index, library_track_data, label and alternate-name trigram indexes (BS#3740) - #3771
Merged
jakebromberg merged 2 commits intoNov 5, 2026
Conversation
…brary.label and alternate_artist_name (BS#3740) Migration 0209 adds the narrow library_track_index table (search_doc tsvector with a GIN index) and its sibling library_track_data, both keyed by library_id with ON DELETE CASCADE, plus trigram GIN indexes on library.label and library.alternate_artist_name. The trigram indexes use IF NOT EXISTS and the header carries the CREATE INDEX CONCURRENTLY commands for the production pre-build. Nothing reads or writes the new tables yet.
4 tasks
Schema constraint shape reportProbed: This PR adds:
one or more probes failed; see above. The check status is non-blocking. |
…ber dedup merge, CHECK library_track_data.source, and pin the full index definitions (BS#3740) Both new tables carry an ON DELETE CASCADE FK into library.id, so the dedup job has to repoint them before it deletes a loser: FK_TARGETS entries keyed on library_id alone (the survivor's row wins, else the loser's row moves), the EXPECTED delete-rule map, the README table, and an integration test of both outcomes. library_track_data.source is limited to compilation, override and album_metadata by a CHECK; migration 0209 is regenerated with the same number. The schema spec now asserts the exact CREATE INDEX definitions, including gin_trgm_ops, and the CHECK.
jakebromberg
deleted the
orchestrator/migration-catalog-search-schema-library-track-inde
branch
November 5, 2026 02:34
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3740
Step 3 of #3738. Adds the catalog search schema as migration
0209_catalog-search-schema. Nothing reads or writes the new tables yet.What changed
library_track_index(library_idinteger PK, FKlibrary.idON DELETE CASCADE;search_doctsvector) with a GIN index onsearch_doc. This is the narrow table the matcher reads.library_track_data(library_idPK, same FK;source,source_batch,discogs_release_id,tracksjsonb,fingerprint,refreshed_at). A record has a row in both tables or in neither. This follows the 2026-11-04 plan-revision comment on Migration: catalog search schema (library_track_index table, label and alternate-name trigram indexes) #3740, which supersedes the single-table design in the issue body.library_label_trgm_idxandlibrary_alternate_artist_name_trgm_idxonlibrary. They are created with a hand-addedIF NOT EXISTS, and the migration header carries the exactCREATE INDEX CONCURRENTLYcommands for the production pre-build (perdocs/migrations.md). The new tables' own indexes are plain, since the tables are empty.tests/mocks/database.mock.tsgets doubles for both tables, ascheck:db-mock-syncrequires.labelstays out ofsearch_doc, notrackscolumn is added tolibrary, and the 500-character title cap is left to the future writer job. Ops builds the two trigram indexes on production before this merges; no production command was run from this PR.Size: about 46 added lines of production source in
schema.ts(much of it comments); the rest is the generated migration and snapshot, tests, and the mock.Acceptance criteria and how each is tested
CONCURRENTLYcommands: applied throughdev_env/init-db.mjs(the same runner CI and deploy use) against a fresh Postgres;npm run lint:migrationspasses with 0 warnings.library_track_index.search_docand both trigram indexes exist after a fresh migrate:tests/integration/library-track-index-schema.spec.jschecks each is a validginindex on the expected column.libraryrow plus a row in each new table, deletes the library row, and asserts both are gone. It also asserts that an orphanlibrary_idis rejected (23503) on both tables.npm run ci:testmock: not run. Docker was not running on the machine and starting Docker Desktop would take over the screen. Instead I ran the integration spec against a private Homebrew PostgreSQL 18 cluster (migrated and seeded viadev_env/init-db.mjs). The repo's other local checks pass:typecheck,format:check,lint:changed(0 errors),check:db-mock-sync,lint:migrations, and the unit suite (761 suites, 16534 tests). Please let CI's integration job confirm.Mutation check: dropping the two indexes and replacing one cascade FK with a plain FK makes three of the six cases fail. I did not mutate the orphan-rejection cases (they pass on any FK), and did not mutate
library_alternate_artist_name_trgm_idxseparately; it uses the same assertion path as the label index.Mirrors:
tests/mocks/database.mock.ts(hand-maintained double, enforced bycheck:db-mock-sync);meta/applied-hashes.jsonand the journal were updated by the repo's scripts.