From 458a18309959517b4e511e1137df8c1728e63185 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Mon, 4 May 2026 14:29:13 -0400 Subject: [PATCH] feat(db/m7-353): add albums.cover_art_source enum column --- .../0016_album_cover_source.down.sql | 3 +++ .../migrations/0016_album_cover_source.up.sql | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 internal/db/migrations/0016_album_cover_source.down.sql create mode 100644 internal/db/migrations/0016_album_cover_source.up.sql 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);