fix(db): V16 补充 conversation 租户时间索引,脚本使用 MYSQL_PWD 避免密码暴露,增加生产部署提示

This commit is contained in:
2026-07-07 18:50:26 +08:00
parent 3b45a669f9
commit 4dbc190f68
3 changed files with 21 additions and 1 deletions

View File

@@ -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消息事件表

View File

@@ -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);