feat: 增加RAG知识库与文档基础骨架

This commit is contained in:
2026-05-18 22:32:53 +08:00
parent 18386fde63
commit 4a20a25282
15 changed files with 360 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
DROP TABLE IF EXISTS rag_document;
CREATE TABLE rag_document (
id BIGSERIAL PRIMARY KEY,
store_id BIGINT NOT NULL,
attachment_id BIGINT NOT NULL,
document_title VARCHAR(255) NOT NULL,
document_summary VARCHAR(1000) DEFAULT '',
parse_status VARCHAR(50) NOT NULL DEFAULT 'UPLOADED',
index_status VARCHAR(50) NOT NULL DEFAULT 'PENDING',
enabled BOOLEAN NOT NULL DEFAULT TRUE,
error_message VARCHAR(1000) DEFAULT '',
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_document_attachment UNIQUE (attachment_id),
CONSTRAINT fk_rag_document_store_id FOREIGN KEY (store_id) REFERENCES rag_store (id),
CONSTRAINT fk_rag_document_attachment_id FOREIGN KEY (attachment_id) REFERENCES sys_attachment (id)
);
CREATE INDEX idx_rag_document_store_id ON rag_document (store_id);
CREATE INDEX idx_rag_document_parse_status ON rag_document (parse_status);
CREATE INDEX idx_rag_document_index_status ON rag_document (index_status);
CREATE INDEX idx_rag_document_enabled ON rag_document (enabled);
COMMENT ON TABLE rag_document IS 'RAG知识库文档表';
COMMENT ON COLUMN rag_document.id IS 'ID';
COMMENT ON COLUMN rag_document.store_id IS '知识库ID';
COMMENT ON COLUMN rag_document.attachment_id IS '附件ID';
COMMENT ON COLUMN rag_document.document_title IS '文档标题';
COMMENT ON COLUMN rag_document.document_summary IS '文档摘要';
COMMENT ON COLUMN rag_document.parse_status IS '解析状态';
COMMENT ON COLUMN rag_document.index_status IS '索引状态';
COMMENT ON COLUMN rag_document.enabled IS '是否启用';
COMMENT ON COLUMN rag_document.error_message IS '失败原因';
COMMENT ON COLUMN rag_document.version IS '版本';
COMMENT ON COLUMN rag_document.create_time IS '创建时间';
COMMENT ON COLUMN rag_document.update_time IS '更新时间';
COMMENT ON COLUMN rag_document.remark IS '备注';
COMMENT ON COLUMN rag_document.create_by IS '创建者';
COMMENT ON COLUMN rag_document.update_by IS '更新者';

32
script/sql/rag_store.sql Normal file
View File

@@ -0,0 +1,32 @@
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 '更新者';