fix(db): V16 补充 conversation 租户时间索引,脚本使用 MYSQL_PWD 避免密码暴露,增加生产部署提示
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
-- Phase 1.5: 为高频表添加 MySQL RANGE 月分区(分区键 create_time)
|
||||
-- 架构设计文档:docs/architecture/2026-07-06-message-customer-interaction-design.md 第 2.6.2 节
|
||||
--
|
||||
-- 生产部署注意:
|
||||
-- 1. 本迁移对主键/唯一键和外键做了破坏性调整,上线前请先在预发布环境用真实数据量验证。
|
||||
-- 2. 大表(message_event / send_record)执行 DROP/ADD PRIMARY KEY 可能锁表,建议使用 pt-online-schema-change
|
||||
-- 或预留低峰窗口;当前脚本为开发/MVP 阶段使用。
|
||||
-- 3. 未提供 down migration:取消分区需要重建表并恢复外键,操作复杂,请在上线前自行备份 schema。
|
||||
|
||||
-- ============================
|
||||
-- 1. mci_message_event(消息事件表)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Phase 1.5 补充:为 mci_conversation 添加架构设计要求的 (tenant_code, create_time) 索引
|
||||
-- 注意:V15 中为了满足 MySQL 分区规则,唯一键已包含 create_time,导致唯一性约束弱化;
|
||||
-- 业务上应通过 event_id / task_id 等自然业务键保证唯一性。
|
||||
ALTER TABLE mci_conversation ADD KEY idx_tenant_time (tenant_code, create_time);
|
||||
Reference in New Issue
Block a user