DROP TABLE IF EXISTS rag_store;

CREATE TABLE rag_store (
    id BIGSERIAL PRIMARY KEY,
    store_code VARCHAR(100) NOT NULL,
    store_name VARCHAR(200) NOT NULL,
    description VARCHAR(1000) DEFAULT '',
    status VARCHAR(50) NOT NULL DEFAULT 'ENABLED',
    version INTEGER NOT NULL DEFAULT 1,
    create_time TIMESTAMP,
    update_time TIMESTAMP,
    remark VARCHAR(500) DEFAULT '',
    create_by VARCHAR(64),
    update_by VARCHAR(64),
    CONSTRAINT uk_rag_store_code UNIQUE (store_code)
);

CREATE INDEX idx_rag_store_status ON rag_store (status);
CREATE INDEX idx_rag_store_create_time ON rag_store (create_time);

COMMENT ON TABLE rag_store IS 'RAG知识库主表';
COMMENT ON COLUMN rag_store.id IS 'ID';
COMMENT ON COLUMN rag_store.store_code IS '知识库编码';
COMMENT ON COLUMN rag_store.store_name IS '知识库名称';
COMMENT ON COLUMN rag_store.description IS '知识库描述';
COMMENT ON COLUMN rag_store.status IS '状态';
COMMENT ON COLUMN rag_store.version IS '版本';
COMMENT ON COLUMN rag_store.create_time IS '创建时间';
COMMENT ON COLUMN rag_store.update_time IS '更新时间';
COMMENT ON COLUMN rag_store.remark IS '备注';
COMMENT ON COLUMN rag_store.create_by IS '创建者';
COMMENT ON COLUMN rag_store.update_by IS '更新者';
