-- Every library album is matched to MusicBrainz before it goes on the list -- (#5569, operator 2026-10-10: "they should all exist in music brainz we -- need to use their meta data or a search system to link them up"). The -- listing in 0085 took only albums whose tags already named their release -- group and artist; the rest are now matched by the release their tags -- name, the artist's discography, or a search, and checked against their -- own tracks. -- -- library_album_matches one row per album the listing has decided: -- listed (with how it was matched) or unmatched -- (with why). It is the record that the listing -- saw the album, so an album taken off the list -- is never listed again. CREATE TABLE library_album_matches ( album_id uuid PRIMARY KEY REFERENCES albums (id) ON DELETE CASCADE, outcome text NOT NULL CONSTRAINT library_album_matches_outcome_check CHECK (outcome IN ('listed', 'unmatched')), -- tags its tags named the release group. -- release its tags named a release; MusicBrainz named the group. -- discography its title is one of the artist's release groups. -- search MusicBrainz's search found it by artist and title. method text NOT NULL DEFAULT '' CONSTRAINT library_album_matches_method_check CHECK (method IN ('', 'tags', 'release', 'discography', 'search')), release_group_mbid text NOT NULL DEFAULT '', detail text NOT NULL DEFAULT '', decided_at timestamptz NOT NULL DEFAULT now() ); CREATE INDEX library_album_matches_unmatched_idx ON library_album_matches (decided_at) WHERE outcome = 'unmatched'; -- The albums 0085's listing already took, by its own test, are decided: -- one taken off the list since stays off. INSERT INTO library_album_matches (album_id, outcome, method, release_group_mbid) SELECT a.id, 'listed', 'tags', a.release_group_mbid FROM albums a JOIN artists ar ON ar.id = a.artist_id JOIN acquisition_settings s ON s.id = true WHERE s.library_listing_started_at IS NOT NULL AND a.created_at <= s.library_listing_started_at AND a.release_group_mbid IS NOT NULL AND a.release_group_mbid <> '' AND ar.mbid IS NOT NULL AND ar.mbid <> '' AND EXISTS (SELECT 1 FROM tracks t WHERE t.album_id = a.id); -- The rest are matched by the wanted worker after boot: the listing resumes. UPDATE acquisition_settings SET library_listed_at = NULL, library_unlisted = 0 WHERE library_listing_started_at IS NOT NULL;