-- Per-URL scan history for dedup against previous scans (beyond jobs.url UNIQUE).
-- Tracks every URL ever seen with status so we can skip expired/filtered without re-fetch.

CREATE TABLE IF NOT EXISTS scanned_urls (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    url TEXT UNIQUE NOT NULL,
    company TEXT NOT NULL,
    title TEXT,
    source TEXT NOT NULL,
    status TEXT NOT NULL DEFAULT 'added',
    first_seen TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    last_seen TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX IF NOT EXISTS idx_scanned_urls_company ON scanned_urls(company);
CREATE INDEX IF NOT EXISTS idx_scanned_urls_status ON scanned_urls(status);
