sonda/migrations/postgres/0003_name_keys.sql
tgiachi d6e9e09ce7 fix(library): harden the scanner against special files, stat errors and lossy logging
- fix: skip FIFOs, sockets and devices named like audio files; opening a named
  pipe blocked a scan forever and left the manager stuck in "running"
- fix: a file that cannot be stat'ed for a transient reason is unknown, not
  gone, so it is never marked missing or used as a rename source
- fix: log the scan result from Manager.OnFinish instead of the lossy event
  hub, so the line can no longer be dropped
- fix(storage): match artists and albums on a Unicode-aware key computed in Go
  (migration 0003, both drivers), so SQLite and PostgreSQL agree
- test: FIFO, stat errors, OnFinish, Unicode artist and album matching
2026-11-11 12:28:44 +01:00

13 lines
639 B
SQL

-- Case-insensitive matching keys for artists and albums.
-- The scanner computes them in Go (Unicode-aware); SQLite's lower() only folds
-- ASCII, so matching in SQL would differ between SQLite and PostgreSQL.
ALTER TABLE artists ADD COLUMN name_key TEXT NOT NULL DEFAULT '';
ALTER TABLE albums ADD COLUMN title_key TEXT NOT NULL DEFAULT '';
-- Best effort for rows that already exist; the scanner keeps them up to date.
UPDATE artists SET name_key = lower(name);
UPDATE albums SET title_key = lower(title);
CREATE INDEX idx_artists_name_key ON artists(name_key);
CREATE INDEX idx_albums_title_key ON albums(title_key, artist_id);