feat(db/m7-353): add albums.cover_art_source enum column

This commit is contained in:
2026-05-04 14:29:13 -04:00
parent 40be3bf917
commit 458a183099
2 changed files with 22 additions and 0 deletions
@@ -0,0 +1,3 @@
DROP INDEX IF EXISTS albums_cover_art_source_idx;
ALTER TABLE albums DROP CONSTRAINT IF EXISTS albums_cover_art_source_check;
ALTER TABLE albums DROP COLUMN IF EXISTS cover_art_source;
@@ -0,0 +1,19 @@
-- M7 #353: album cover origin attribution.
-- 'embedded' — extracted from audio file (reserved for future slice).
-- 'sidecar' — found in the album directory (cover.jpg/folder.jpg/etc).
-- 'mbcaa' — fetched from MusicBrainz Cover Art Archive.
-- 'none' — tried, no cover available. Skip auto-retry; only manual.
ALTER TABLE albums ADD COLUMN cover_art_source text;
ALTER TABLE albums
ADD CONSTRAINT albums_cover_art_source_check
CHECK (cover_art_source IS NULL
OR cover_art_source IN ('embedded', 'sidecar', 'mbcaa', 'none'));
-- Backfill existing rows with cover_art_path set (defensive: scanner has
-- never populated cover_art_path in current dev, but keeps re-runs idempotent).
UPDATE albums SET cover_art_source = 'sidecar'
WHERE cover_art_path IS NOT NULL AND cover_art_source IS NULL;
-- Index supports "find missing covers" queries.
CREATE INDEX albums_cover_art_source_idx ON albums (cover_art_source);