-- 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);