diff --git a/internal/db/migrations/0016_album_cover_source.down.sql b/internal/db/migrations/0016_album_cover_source.down.sql new file mode 100644 index 00000000..86c33bed --- /dev/null +++ b/internal/db/migrations/0016_album_cover_source.down.sql @@ -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; diff --git a/internal/db/migrations/0016_album_cover_source.up.sql b/internal/db/migrations/0016_album_cover_source.up.sql new file mode 100644 index 00000000..ff2f718f --- /dev/null +++ b/internal/db/migrations/0016_album_cover_source.up.sql @@ -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);