Files
customer-server/update.sql

94 lines
5.1 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-----------张斌2025-06-16 15:00:00--------------
--------------------pgsql创建customer_server_account表语句---------------------------
-- 客服账号表RAG智能客服
CREATE TABLE IF NOT EXISTS customer_server_account (
-- 基础字段(完全对齐项目规范)
id BIGINT PRIMARY KEY, -- 主键ID非自增
tenant_id BIGINT NOT NULL DEFAULT 0, -- 租户ID int8
creator VARCHAR(64) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(64) NOT NULL,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted_at timestamp(6),
-- 业务字段
account_name VARCHAR(128) NOT NULL, -- 客服账号名称
status SMALLINT NOT NULL DEFAULT 1, -- 状态1启用/0停用
platform VARCHAR(32) NOT NULL, -- 客服平台
greeting TEXT DEFAULT '', -- 开场白
prompt TEXT[] DEFAULT '{}', -- 提示词数组
self_identity TEXT DEFAULT '', -- AI身份描述
dataset_ids BIGINT[] DEFAULT '{}', -- 绑定的数据集ID列表
document_ids BIGINT[] DEFAULT '{}', -- 绑定的文档ID列表
expand_data JSONB DEFAULT '{}'::JSONB -- 扩展数据(JSONB)
);
-- 索引(高频查询)
CREATE INDEX idx_csa_tenant_id ON customer_server_account(tenant_id);
CREATE INDEX idx_csa_account_name ON customer_server_account(account_name);
CREATE INDEX idx_csa_status ON customer_server_account(status);
CREATE INDEX idx_csa_platform ON customer_server_account(platform);
CREATE INDEX idx_csa_deleted_at ON customer_server_account(deleted_at);
-- 表和字段注释
COMMENT ON TABLE customer_server_account IS '客服账号表RAG智能客服配置';
COMMENT ON COLUMN customer_server_account.id IS '主键ID非自增';
COMMENT ON COLUMN customer_server_account.tenant_id IS '租户ID';
COMMENT ON COLUMN customer_server_account.creator IS '创建人';
COMMENT ON COLUMN customer_server_account.created_at IS '创建时间';
COMMENT ON COLUMN customer_server_account.updater IS '更新人';
COMMENT ON COLUMN customer_server_account.updated_at IS '更新时间';
COMMENT ON COLUMN customer_server_account.deleted_at IS '删除时间(软删)';
COMMENT ON COLUMN customer_server_account.account_name IS '客服账号名称';
COMMENT ON COLUMN customer_server_account.status IS '客服账号状态';
COMMENT ON COLUMN customer_server_account.platform IS '客服平台';
COMMENT ON COLUMN customer_server_account.greeting IS '开场白';
COMMENT ON COLUMN customer_server_account.prompt IS '提示词数组';
COMMENT ON COLUMN customer_server_account.self_identity IS 'AI身份描述';
COMMENT ON COLUMN customer_server_account.dataset_ids IS '绑定的数据集ID列表';
COMMENT ON COLUMN customer_server_account.document_ids IS '绑定的文档ID列表';
COMMENT ON COLUMN customer_server_account.expand_data IS '扩展数据(JSONB)';
--------------------pgsql创建customer_server_account表语句---------------------------
--------------------pgsql创建customer_server_scripted_speech表语句---------------------------
-- 客服话术表(自定义问答话术)
CREATE TABLE IF NOT EXISTS customer_server_scripted_speech (
-- 基础字段(完全对齐项目规范)
id BIGINT PRIMARY KEY, -- 主键ID非自增
tenant_id BIGINT NOT NULL DEFAULT 0, -- 租户ID int8
creator VARCHAR(64) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(64) NOT NULL,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
deleted_at timestamp(6),
-- 业务字段
account_id BIGINT NOT NULL, -- 账号ID
dataset_id BIGINT NOT NULL, -- 数据集ID
question_content TEXT NOT NULL, -- 问题内容
answer_content TEXT NOT NULL -- 回答内容
);
-- 索引(高频查询)
CREATE INDEX idx_csss_tenant_id ON customer_server_scripted_speech(tenant_id);
CREATE INDEX idx_csss_account_id ON customer_server_scripted_speech(account_id);
CREATE INDEX idx_csss_dataset_id ON customer_server_scripted_speech(dataset_id);
CREATE INDEX idx_csss_deleted_at ON customer_server_scripted_speech(deleted_at);
-- 表和字段注释
COMMENT ON TABLE customer_server_scripted_speech IS '客服话术表(自定义问答话术)';
COMMENT ON COLUMN customer_server_scripted_speech.id IS '主键ID非自增';
COMMENT ON COLUMN customer_server_scripted_speech.tenant_id IS '租户ID';
COMMENT ON COLUMN customer_server_scripted_speech.creator IS '创建人';
COMMENT ON COLUMN customer_server_scripted_speech.created_at IS '创建时间';
COMMENT ON COLUMN customer_server_scripted_speech.updater IS '更新人';
COMMENT ON COLUMN customer_server_scripted_speech.updated_at IS '更新时间';
COMMENT ON COLUMN customer_server_scripted_speech.deleted_at IS '删除时间(软删)';
COMMENT ON COLUMN customer_server_scripted_speech.account_id IS '账号ID';
COMMENT ON COLUMN customer_server_scripted_speech.dataset_id IS '数据集ID';
COMMENT ON COLUMN customer_server_scripted_speech.question_content IS '问题内容';
COMMENT ON COLUMN customer_server_scripted_speech.answer_content IS '回答内容';
--------------------pgsql创建customer_server_scripted_speech表语句---------------------------