-- V011: ai_knowledge_files
-- AI 지식 파일 테이블 (RAG 문서 저장)

CREATE TABLE ai_knowledge_files (
    id               BIGSERIAL PRIMARY KEY,
    name             VARCHAR(300) NOT NULL,
    file_name        VARCHAR(300),
    category         VARCHAR(100),
    description      TEXT,
    content          TEXT NOT NULL,
    file_size        BIGINT NOT NULL DEFAULT 0,
    mime_type        VARCHAR(100),
    company_code     VARCHAR(20),
    created_by       VARCHAR(64) NOT NULL,
    created_at       TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at       TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_knowledge_category ON ai_knowledge_files (category);
CREATE INDEX idx_knowledge_company  ON ai_knowledge_files (company_code);
