-- 2026-05-18 PR-Worker-Pool-Registry-1A: worker_capabilities 테이블 신규.
-- 노트북 등 worker 가 register 시 advertise 한 device/tier/capability 1 row UPSERT.
-- worker-pool-policy §1 invariant: 노트북 = optional session worker (24/7 X, extraction backbone X).
-- 1A 단계: schema only (라우트 5개 모두 503 stub). register 활성화 = 1B (laptop-worker-bot user).
-- enum 컬럼 (worker_class, tier) 도 TEXT — policy §3,§5 가 capability bundle 을 docs 결정으로 못박음.
-- user_id NOT NULL: 1A 에서는 503 stub 이라 runtime INSERT 없음. 첫 INSERT = 1B JWT 활성화와 동시점.

CREATE TABLE IF NOT EXISTS worker_capabilities (
    worker_id          TEXT PRIMARY KEY,
    user_id            BIGINT NOT NULL REFERENCES users(id) ON DELETE RESTRICT,
    device_label       TEXT NOT NULL,
    worker_class       TEXT NOT NULL,
    tier               TEXT NOT NULL,
    capabilities       JSONB NOT NULL DEFAULT '[]'::jsonb,
    models_loaded      JSONB NOT NULL DEFAULT '[]'::jsonb,
    endpoint           TEXT,
    created_at         TIMESTAMPTZ NOT NULL DEFAULT now(),
    last_registered_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
