-- 0004_metadata.sql — record which providers have been tried for an item. -- -- provider_ids records the match that was chosen. This table records the -- attempt, including failures, so a rescan or a restart does not re-hammer a -- rate-limited API for an item that will never match. CREATE TABLE metadata_fetch ( item_id INTEGER NOT NULL REFERENCES media_items(id) ON DELETE CASCADE, provider TEXT NOT NULL, status TEXT NOT NULL, -- ok | notfound | error detail TEXT NOT NULL DEFAULT '', fetched_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')), PRIMARY KEY (item_id, provider) ); CREATE INDEX idx_metadata_fetch_item ON metadata_fetch(item_id);