2025-08-05 07:08:07 +00:00
|
|
|
DROP TABLE IF EXISTS tenants;
|
|
|
|
|
DROP TABLE IF EXISTS models;
|
|
|
|
|
DROP TABLE IF EXISTS knowledge_bases;
|
|
|
|
|
DROP TABLE IF EXISTS knowledges;
|
|
|
|
|
DROP TABLE IF EXISTS sessions;
|
|
|
|
|
DROP TABLE IF EXISTS messages;
|
|
|
|
|
DROP TABLE IF EXISTS chunks;
|
|
|
|
|
|
|
|
|
|
CREATE TABLE tenants (
|
|
|
|
|
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
|
name VARCHAR(255) NOT NULL,
|
|
|
|
|
description TEXT,
|
|
|
|
|
retriever_engines JSON NOT NULL,
|
|
|
|
|
status VARCHAR(50) DEFAULT 'active',
|
|
|
|
|
business VARCHAR(255) NOT NULL,
|
|
|
|
|
storage_quota BIGINT NOT NULL DEFAULT 10737418240,
|
|
|
|
|
storage_used BIGINT NOT NULL DEFAULT 0,
|
2025-11-05 15:18:44 +00:00
|
|
|
agent_config JSON DEFAULT NULL COMMENT 'Tenant-level agent configuration in JSON format',
|
2025-08-05 07:08:07 +00:00
|
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
|
deleted_at TIMESTAMP NULL DEFAULT NULL
|
2025-08-10 09:04:39 +00:00
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=10000;
|
2025-08-05 07:08:07 +00:00
|
|
|
|
|
|
|
|
CREATE TABLE models (
|
2025-08-09 12:58:02 +00:00
|
|
|
id VARCHAR(64) PRIMARY KEY,
|
2025-08-05 07:08:07 +00:00
|
|
|
tenant_id INT NOT NULL,
|
|
|
|
|
name VARCHAR(255) NOT NULL,
|
2026-05-28 10:36:38 +00:00
|
|
|
display_name VARCHAR(255) NOT NULL DEFAULT '',
|
2025-08-05 07:08:07 +00:00
|
|
|
type VARCHAR(50) NOT NULL,
|
|
|
|
|
source VARCHAR(50) NOT NULL,
|
|
|
|
|
description TEXT,
|
|
|
|
|
parameters JSON NOT NULL,
|
|
|
|
|
is_default BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
|
status VARCHAR(50) NOT NULL DEFAULT 'active',
|
|
|
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
|
deleted_at TIMESTAMP NULL DEFAULT NULL
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
|
|
|
|
|
|
CREATE INDEX idx_models_tenant_source_type ON models(tenant_id, source, type);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE knowledge_bases (
|
|
|
|
|
id VARCHAR(36) PRIMARY KEY,
|
|
|
|
|
name VARCHAR(255) NOT NULL,
|
|
|
|
|
description TEXT,
|
|
|
|
|
tenant_id INT NOT NULL,
|
|
|
|
|
chunking_config JSON NOT NULL,
|
|
|
|
|
image_processing_config JSON NOT NULL,
|
2025-08-09 12:58:02 +00:00
|
|
|
embedding_model_id VARCHAR(64) NOT NULL,
|
|
|
|
|
summary_model_id VARCHAR(64) NOT NULL,
|
2025-08-10 09:04:39 +00:00
|
|
|
rerank_model_id VARCHAR(64) NOT NULL,
|
|
|
|
|
cos_config JSON NOT NULL,
|
|
|
|
|
vlm_config JSON NOT NULL,
|
2025-09-24 04:15:17 +00:00
|
|
|
extract_config JSON NULL,
|
2026-08-05 13:56:58 +00:00
|
|
|
auto_tag_config JSON NULL,
|
feat(knowledge): derive knowledge base descriptions from document profiles (#3370)
* feat(knowledge): derive knowledge base descriptions from document profiles
Knowledge bases only had a hand-written description, which most users
leave empty, so agents bound to several knowledge bases had nothing to
route on and searched all of them. This adds a generated description
that is derived from per-document data instead of maintained by a model.
Document profile: the summary call now returns JSON with a 2-3 sentence
summary plus a gist, 3-5 topic keywords, a document type and one
typical question (knowledges.profile). Input is capped at 8k chars and
output at 1024 tokens; plain-text replies from custom templates still
work and simply carry no profile. The summary chunk embeds the gist and
short summary.
Knowledge base aggregate: a database-only fold over those rows (counts
per file type, tag, normalized topic and doc type; stratified samples of
titles and questions; a hash of the inputs). Deleting, moving or
re-parsing a document changes nothing but the rows, so the next rebuild
is exact without any model judgement.
Description text: one small model call over the aggregate yields a
gist, merged topics and typical questions (knowledge_bases.
generated_profile). The call is skipped when the aggregate hash is
unchanged; failures keep the previous text and record the error; an
empty knowledge base clears it. The manual description is never
touched, and the agent runtime context renders both so the model can
pass knowledge_base_ids instead of fanning out.
Refreshes are requested from summary task exit, post-process completion,
deletion, cross-KB moves and enabling the option, debounced per
knowledge base in 30 s windows via kb:profile on the summary queue.
POST /knowledge-bases/:id/profile/generate regenerates synchronously.
profile_config (enabled, model_id, custom_instructions) opts a document
knowledge base in; the settings dialog shows the generated card with
regenerate and adopt-as-description actions in five locales. Search
results now log hits per chunk type so the value of indexing summary
chunks can be measured.
Migrations 000101 (PostgreSQL) and 000021 (SQLite) add the columns; the
SQLite schema test expects the new version and columns.
* fix(knowledge): keep generated descriptions out of duplicates and refresh clones
DuplicateKnowledgeBase copies the source row through JSON, which carried
generated_profile onto a knowledge base that has no documents yet, so
an empty duplicate advertised the source's topics. The duplicate now
starts without a generated description and keeps profile_config so it
derives its own once documents arrive.
CopyKnowledgeBase builds the target field by field and skipped
profile_config, and the clone task never asked for a description after
copying the documents, so a clone stayed undescribed until its next
upload. The target now carries a copy of profile_config and both clone
paths request a refresh on completion.
* fix(knowledge): refresh the loaded clone target and carry document profiles
ProcessKBClone requested the description refresh with the reservation
stub it builds before CopyKnowledgeBase runs. For the main create path
that stub has neither a type nor profile_config, so the refresh helper
rejected it and nothing was enqueued. The refresh now uses the loaded
target returned by CopyKnowledgeBase.
cloneKnowledge copied the summary text but not the structured profile,
so even a scheduled refresh would have aggregated titles without topics
until every clone was re-summarized. Cloned documents now carry an
independent copy of the profile.
2026-09-17 14:21:55 +00:00
|
|
|
profile_config JSON NULL,
|
|
|
|
|
generated_profile JSON NULL,
|
2025-08-05 07:08:07 +00:00
|
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
|
deleted_at TIMESTAMP NULL DEFAULT NULL
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
|
|
|
|
|
|
CREATE INDEX idx_knowledge_bases_tenant_name ON knowledge_bases(tenant_id, name);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE knowledges (
|
|
|
|
|
id VARCHAR(36) PRIMARY KEY,
|
|
|
|
|
tenant_id INT NOT NULL,
|
|
|
|
|
knowledge_base_id VARCHAR(36) NOT NULL,
|
|
|
|
|
type VARCHAR(50) NOT NULL,
|
|
|
|
|
title VARCHAR(255) NOT NULL,
|
|
|
|
|
description TEXT,
|
2026-06-04 13:05:07 +00:00
|
|
|
source VARCHAR(2048) NOT NULL,
|
2025-08-05 07:08:07 +00:00
|
|
|
parse_status VARCHAR(50) NOT NULL DEFAULT 'unprocessed',
|
|
|
|
|
enable_status VARCHAR(50) NOT NULL DEFAULT 'enabled',
|
2025-08-09 12:58:02 +00:00
|
|
|
embedding_model_id VARCHAR(64),
|
2025-08-05 07:08:07 +00:00
|
|
|
file_name VARCHAR(255),
|
|
|
|
|
file_type VARCHAR(50),
|
|
|
|
|
file_size BIGINT,
|
|
|
|
|
file_path TEXT,
|
|
|
|
|
file_hash VARCHAR(64),
|
|
|
|
|
storage_size BIGINT NOT NULL DEFAULT 0,
|
|
|
|
|
metadata JSON,
|
feat(knowledge): derive knowledge base descriptions from document profiles (#3370)
* feat(knowledge): derive knowledge base descriptions from document profiles
Knowledge bases only had a hand-written description, which most users
leave empty, so agents bound to several knowledge bases had nothing to
route on and searched all of them. This adds a generated description
that is derived from per-document data instead of maintained by a model.
Document profile: the summary call now returns JSON with a 2-3 sentence
summary plus a gist, 3-5 topic keywords, a document type and one
typical question (knowledges.profile). Input is capped at 8k chars and
output at 1024 tokens; plain-text replies from custom templates still
work and simply carry no profile. The summary chunk embeds the gist and
short summary.
Knowledge base aggregate: a database-only fold over those rows (counts
per file type, tag, normalized topic and doc type; stratified samples of
titles and questions; a hash of the inputs). Deleting, moving or
re-parsing a document changes nothing but the rows, so the next rebuild
is exact without any model judgement.
Description text: one small model call over the aggregate yields a
gist, merged topics and typical questions (knowledge_bases.
generated_profile). The call is skipped when the aggregate hash is
unchanged; failures keep the previous text and record the error; an
empty knowledge base clears it. The manual description is never
touched, and the agent runtime context renders both so the model can
pass knowledge_base_ids instead of fanning out.
Refreshes are requested from summary task exit, post-process completion,
deletion, cross-KB moves and enabling the option, debounced per
knowledge base in 30 s windows via kb:profile on the summary queue.
POST /knowledge-bases/:id/profile/generate regenerates synchronously.
profile_config (enabled, model_id, custom_instructions) opts a document
knowledge base in; the settings dialog shows the generated card with
regenerate and adopt-as-description actions in five locales. Search
results now log hits per chunk type so the value of indexing summary
chunks can be measured.
Migrations 000101 (PostgreSQL) and 000021 (SQLite) add the columns; the
SQLite schema test expects the new version and columns.
* fix(knowledge): keep generated descriptions out of duplicates and refresh clones
DuplicateKnowledgeBase copies the source row through JSON, which carried
generated_profile onto a knowledge base that has no documents yet, so
an empty duplicate advertised the source's topics. The duplicate now
starts without a generated description and keeps profile_config so it
derives its own once documents arrive.
CopyKnowledgeBase builds the target field by field and skipped
profile_config, and the clone task never asked for a description after
copying the documents, so a clone stayed undescribed until its next
upload. The target now carries a copy of profile_config and both clone
paths request a refresh on completion.
* fix(knowledge): refresh the loaded clone target and carry document profiles
ProcessKBClone requested the description refresh with the reservation
stub it builds before CopyKnowledgeBase runs. For the main create path
that stub has neither a type nor profile_config, so the refresh helper
rejected it and nothing was enqueued. The refresh now uses the loaded
target returned by CopyKnowledgeBase.
cloneKnowledge copied the summary text but not the structured profile,
so even a scheduled refresh would have aggregated titles without topics
until every clone was re-summarized. Cloned documents now carry an
independent copy of the profile.
2026-09-17 14:21:55 +00:00
|
|
|
profile JSON,
|
2026-07-28 14:19:26 +00:00
|
|
|
custom_metadata JSON NOT NULL,
|
2025-08-05 07:08:07 +00:00
|
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
|
deleted_at TIMESTAMP NULL DEFAULT NULL,
|
|
|
|
|
processed_at TIMESTAMP,
|
2025-10-21 01:42:09 +00:00
|
|
|
error_message TEXT
|
2025-08-05 07:08:07 +00:00
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
|
|
|
|
|
|
CREATE INDEX idx_knowledges_tenant_id ON knowledges(tenant_id, knowledge_base_id);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE sessions (
|
|
|
|
|
id VARCHAR(36) PRIMARY KEY,
|
|
|
|
|
tenant_id INTEGER NOT NULL,
|
|
|
|
|
title VARCHAR(255),
|
|
|
|
|
description TEXT,
|
|
|
|
|
knowledge_base_id VARCHAR(36),
|
|
|
|
|
max_rounds INT NOT NULL DEFAULT 5,
|
|
|
|
|
enable_rewrite BOOLEAN NOT NULL DEFAULT TRUE,
|
|
|
|
|
fallback_strategy VARCHAR(255) NOT NULL DEFAULT 'fixed',
|
|
|
|
|
fallback_response VARCHAR(255) NOT NULL DEFAULT '很抱歉,我暂时无法回答这个问题。',
|
|
|
|
|
keyword_threshold FLOAT NOT NULL DEFAULT 0.5,
|
|
|
|
|
vector_threshold FLOAT NOT NULL DEFAULT 0.5,
|
2025-08-09 12:58:02 +00:00
|
|
|
rerank_model_id VARCHAR(64),
|
2025-08-05 07:08:07 +00:00
|
|
|
embedding_top_k INTEGER NOT NULL DEFAULT 10,
|
|
|
|
|
rerank_top_k INTEGER NOT NULL DEFAULT 10,
|
|
|
|
|
rerank_threshold FLOAT NOT NULL DEFAULT 0.65,
|
2025-08-09 12:58:02 +00:00
|
|
|
summary_model_id VARCHAR(64),
|
2025-08-05 07:08:07 +00:00
|
|
|
summary_parameters JSON NOT NULL,
|
2025-11-05 15:18:44 +00:00
|
|
|
agent_config JSON DEFAULT NULL COMMENT 'Session-level agent configuration in JSON format',
|
|
|
|
|
context_config JSON DEFAULT NULL COMMENT 'LLM context management configuration (separate from message storage)',
|
2025-08-05 07:08:07 +00:00
|
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
|
deleted_at TIMESTAMP NULL DEFAULT NULL
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
|
|
|
|
|
|
CREATE INDEX idx_sessions_tenant_id ON sessions(tenant_id);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE messages (
|
|
|
|
|
id VARCHAR(36) PRIMARY KEY,
|
|
|
|
|
request_id VARCHAR(36) NOT NULL,
|
|
|
|
|
session_id VARCHAR(36) NOT NULL,
|
|
|
|
|
role VARCHAR(50) NOT NULL,
|
|
|
|
|
content TEXT NOT NULL,
|
|
|
|
|
knowledge_references JSON NOT NULL,
|
2025-11-05 15:18:44 +00:00
|
|
|
agent_steps JSON DEFAULT NULL COMMENT 'Agent execution steps (reasoning process and tool calls)',
|
2025-08-05 07:08:07 +00:00
|
|
|
is_completed BOOLEAN NOT NULL DEFAULT FALSE,
|
2026-07-14 03:06:13 +00:00
|
|
|
agent_id VARCHAR(36) NOT NULL DEFAULT '',
|
|
|
|
|
agent_tenant_id INTEGER NOT NULL DEFAULT 0,
|
|
|
|
|
model_id VARCHAR(64) NOT NULL DEFAULT '',
|
|
|
|
|
execution_context JSON NOT NULL,
|
2025-08-05 07:08:07 +00:00
|
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
|
deleted_at TIMESTAMP NULL DEFAULT NULL
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
|
|
|
|
|
|
CREATE INDEX idx_messages_session_role ON messages(session_id, role);
|
2026-07-14 03:06:13 +00:00
|
|
|
CREATE INDEX idx_messages_agent_id ON messages(agent_id);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE message_suggestion_sets (
|
|
|
|
|
id VARCHAR(36) PRIMARY KEY,
|
|
|
|
|
tenant_id INTEGER NOT NULL,
|
|
|
|
|
session_id VARCHAR(36) NOT NULL,
|
|
|
|
|
assistant_message_id VARCHAR(36) NOT NULL,
|
|
|
|
|
agent_id VARCHAR(36) NOT NULL DEFAULT '',
|
|
|
|
|
agent_tenant_id INTEGER NOT NULL DEFAULT 0,
|
|
|
|
|
placement VARCHAR(32) NOT NULL,
|
|
|
|
|
config_hash VARCHAR(64) NOT NULL,
|
|
|
|
|
locale VARCHAR(16) NOT NULL DEFAULT '',
|
|
|
|
|
status VARCHAR(16) NOT NULL,
|
|
|
|
|
allow_regenerate BOOLEAN NOT NULL DEFAULT FALSE,
|
|
|
|
|
suppression_reason VARCHAR(64) NOT NULL DEFAULT '',
|
|
|
|
|
questions JSON NOT NULL,
|
|
|
|
|
model_id VARCHAR(64) NOT NULL DEFAULT '',
|
|
|
|
|
prompt_tokens INTEGER NOT NULL DEFAULT 0,
|
|
|
|
|
completion_tokens INTEGER NOT NULL DEFAULT 0,
|
|
|
|
|
latency_ms BIGINT NOT NULL DEFAULT 0,
|
|
|
|
|
error_code VARCHAR(64) NOT NULL DEFAULT '',
|
|
|
|
|
lease_until TIMESTAMP NULL DEFAULT NULL,
|
|
|
|
|
generated_at TIMESTAMP NULL DEFAULT NULL,
|
|
|
|
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
|
UNIQUE KEY idx_message_suggestion_sets_cache_key
|
|
|
|
|
(tenant_id, assistant_message_id, placement, config_hash, locale),
|
|
|
|
|
KEY idx_message_suggestion_sets_session (tenant_id, session_id, created_at),
|
|
|
|
|
KEY idx_message_suggestion_sets_status (status, lease_until)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
|
|
|
|
|
|
CREATE TABLE message_suggestion_events (
|
|
|
|
|
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
|
tenant_id INTEGER NOT NULL,
|
|
|
|
|
session_id VARCHAR(36) NOT NULL,
|
|
|
|
|
suggestion_set_id VARCHAR(36) NOT NULL,
|
|
|
|
|
question_id VARCHAR(64) NOT NULL DEFAULT '',
|
|
|
|
|
event_type VARCHAR(32) NOT NULL,
|
|
|
|
|
actor_id VARCHAR(512) NOT NULL DEFAULT '',
|
|
|
|
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
KEY idx_message_suggestion_events_set (suggestion_set_id, created_at),
|
|
|
|
|
KEY idx_message_suggestion_events_session (tenant_id, session_id, created_at),
|
|
|
|
|
KEY idx_message_suggestion_events_type (event_type, created_at),
|
|
|
|
|
CONSTRAINT fk_message_suggestion_events_set
|
|
|
|
|
FOREIGN KEY (suggestion_set_id) REFERENCES message_suggestion_sets(id) ON DELETE CASCADE
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
2025-08-05 07:08:07 +00:00
|
|
|
|
|
|
|
|
CREATE TABLE chunks (
|
|
|
|
|
id VARCHAR(36) PRIMARY KEY,
|
|
|
|
|
tenant_id INTEGER NOT NULL,
|
|
|
|
|
knowledge_base_id VARCHAR(36) NOT NULL,
|
|
|
|
|
knowledge_id VARCHAR(36) NOT NULL,
|
|
|
|
|
content TEXT NOT NULL,
|
2026-07-28 03:39:20 +00:00
|
|
|
source_content TEXT NOT NULL,
|
|
|
|
|
content_revision INT NOT NULL DEFAULT 0,
|
|
|
|
|
index_status VARCHAR(16) NOT NULL DEFAULT 'ready',
|
|
|
|
|
last_editor_id VARCHAR(64) NOT NULL DEFAULT '',
|
|
|
|
|
context_header TEXT NOT NULL,
|
2025-08-05 07:08:07 +00:00
|
|
|
chunk_index INTEGER NOT NULL,
|
|
|
|
|
is_enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
|
|
|
|
start_at INTEGER NOT NULL,
|
|
|
|
|
end_at INTEGER NOT NULL,
|
|
|
|
|
pre_chunk_id VARCHAR(36),
|
|
|
|
|
next_chunk_id VARCHAR(36),
|
|
|
|
|
chunk_type VARCHAR(20) NOT NULL DEFAULT 'text',
|
|
|
|
|
parent_chunk_id VARCHAR(36),
|
|
|
|
|
image_info TEXT,
|
|
|
|
|
relation_chunks JSON,
|
|
|
|
|
indirect_relation_chunks JSON,
|
|
|
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
|
deleted_at TIMESTAMP NULL DEFAULT NULL
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
|
|
|
|
|
|
|
|
CREATE INDEX idx_chunks_tenant_knowledge ON chunks(tenant_id, knowledge_id);
|
|
|
|
|
CREATE INDEX idx_chunks_parent_id ON chunks(parent_chunk_id);
|
2025-10-21 01:42:09 +00:00
|
|
|
CREATE INDEX idx_chunks_chunk_type ON chunks(chunk_type);
|
2026-07-28 03:39:20 +00:00
|
|
|
|
|
|
|
|
CREATE TABLE chunk_revisions (
|
|
|
|
|
id VARCHAR(36) PRIMARY KEY,
|
|
|
|
|
tenant_id BIGINT NOT NULL,
|
|
|
|
|
knowledge_base_id VARCHAR(36) NOT NULL,
|
|
|
|
|
knowledge_id VARCHAR(36) NOT NULL,
|
|
|
|
|
chunk_id VARCHAR(36) NOT NULL,
|
|
|
|
|
revision INT NOT NULL,
|
|
|
|
|
content TEXT NOT NULL,
|
|
|
|
|
is_enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
|
|
|
|
editor_id VARCHAR(64) NOT NULL DEFAULT '',
|
|
|
|
|
edit_source VARCHAR(16) NOT NULL DEFAULT 'user',
|
|
|
|
|
edited_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
|
UNIQUE KEY idx_chunk_revisions_chunk_revision (chunk_id, revision),
|
|
|
|
|
KEY idx_chunk_revisions_tenant_chunk (tenant_id, chunk_id)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|