-- knowledge_queue table for processing pipeline
CREATE TABLE knowledge_queue (
    id               VARCHAR2(36)   DEFAULT SYS_GUID() PRIMARY KEY,
    input_type       VARCHAR2(20)   NOT NULL,   -- 'youtube' | 'url' | 'text'
    content          CLOB           NOT NULL,   -- URL or raw text
    status           VARCHAR2(20)   DEFAULT 'pending' NOT NULL,
                                                -- pending | processing | done | error
    title            VARCHAR2(500),             -- LLM-extracted title (after processing)
    error_msg        CLOB,
    metadata_json    CLOB,                      -- JSON: summary, tags, author, etc.
    telegram_chat_id VARCHAR2(50),              -- for future notification support
    created_at       TIMESTAMP      DEFAULT SYSTIMESTAMP NOT NULL,
    updated_at       TIMESTAMP      DEFAULT SYSTIMESTAMP NOT NULL
);

CREATE INDEX idx_kq_status ON knowledge_queue (status, created_at);
