-- Runtime-editable application settings, keyed by subsystem group.
--
-- Mirrors the small key-value `crawler_state` table (0015): one row per
-- group ('crawler' | 'analysis'), the `value` JSONB holding a serialized
-- settings DTO. Env vars seed a row on first boot (when absent); after that
-- the DB row is the source of truth and the admin dashboard edits it live.
--
-- Only operationally-safe fields are stored here — host/infra and secrets
-- (chromium paths, proxy, TOR control, vision API key, cookie domain) stay
-- env-only and are never persisted.
CREATE TABLE app_settings (
    key        text PRIMARY KEY,
    value      jsonb NOT NULL,
    updated_at timestamptz NOT NULL DEFAULT now()
);
