a86897b35e
Adds the schema for the pluggable cover-art provider abstraction: - Extends albums.cover_art_source CHECK to accept 'theaudiodb' (the constraint from migration 0016 only allowed embedded/sidecar/mbcaa/ none, which would block writes from the new provider). - Adds artist_thumb_path / artist_fanart_path / artist_art_source on artists, with a parallel CHECK constraint and source index. - Adds *_sources_version stamps on both albums and artists for the per-row recheck eligibility logic. Default 0 so every existing row becomes stale relative to the seeded current_version=1, retrying through the new chain on first scan after migrate. - New cover_art_provider_settings table (per-provider enabled / api_key / display_order) and cover_art_sources_meta singleton holding current_version. Seeds both v1 providers (mbcaa + theaudiodb) as enabled. - New artist_art_enrich jsonb column on scan_runs for the 4th scan-orchestrator stage tally. The seed leaves theaudiodb.api_key NULL; the application supplies the upstream's documented test key (2) as the default when the column is NULL, per the no-coercive-settings principle.
27 lines
1.2 KiB
SQL
27 lines
1.2 KiB
SQL
-- Reverse of 0018.
|
|
|
|
ALTER TABLE scan_runs DROP COLUMN IF EXISTS artist_art_enrich;
|
|
|
|
DROP TABLE IF EXISTS cover_art_sources_meta;
|
|
DROP TABLE IF EXISTS cover_art_provider_settings;
|
|
|
|
ALTER TABLE artists DROP COLUMN IF EXISTS artist_art_sources_version;
|
|
ALTER TABLE albums DROP COLUMN IF EXISTS cover_art_sources_version;
|
|
|
|
DROP INDEX IF EXISTS artists_artist_art_source_idx;
|
|
ALTER TABLE artists DROP CONSTRAINT IF EXISTS artists_artist_art_source_check;
|
|
ALTER TABLE artists DROP COLUMN IF EXISTS artist_art_source;
|
|
ALTER TABLE artists DROP COLUMN IF EXISTS artist_fanart_path;
|
|
ALTER TABLE artists DROP COLUMN IF EXISTS artist_thumb_path;
|
|
|
|
-- Restore the original albums.cover_art_source CHECK from migration 0016.
|
|
ALTER TABLE albums DROP CONSTRAINT IF EXISTS albums_cover_art_source_check;
|
|
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'));
|
|
-- Note: rows with cover_art_source='theaudiodb' will be rejected by this
|
|
-- restored constraint. If down-migrating from a populated DB, run:
|
|
-- UPDATE albums SET cover_art_source = NULL WHERE cover_art_source = 'theaudiodb';
|
|
-- before applying this migration.
|