-- 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.
