Files
zyt/server/sql/1.9.20260709/alter_qywx_contact_allow_duplicate_rows.sql
T
2026-07-15 09:07:29 +08:00

11 lines
811 B
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.
-- 企微客户表:允许同一 external_userid 多行(每次"添加"新增一条记录)
-- 背景:产品要求与企微「全部客户」展示对齐——客户被删除后重新添加、或被其他员工再次添加时,
-- 不覆盖原纪录,而是新增一行并打 readd_flag=1(以前加过),原有行保持不变。
-- 落库逻辑同步调整(CustomerLogic):
-- * 回调 add_external_contact 且已有该客户 → INSERT 新行(readd_flag=1);
-- * 其他事件 / 全量同步 → 只更新该客户"最新一行"(MAX(id)),不再依赖唯一键 UPSERT
-- * 彻底流失(84061)→ 该客户所有行一并软删。
ALTER TABLE `zyt_qywx_external_contact`
DROP INDEX `uk_external_userid`,
ADD INDEX `idx_external_userid` (`external_userid`);