Files
shanxia2.0/docs/crm-migration/plans/clue/02-database.md
T
2026-06-01 08:21:21 +08:00

43 lines
1.4 KiB
Markdown
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.
# 线索管理模块迁移方案 — 02 数据库
> 权威 DDL:`docs/sql/incremental_crm_clue.sql`(已按门户 7 项公共字段适配)
---
## 表清单
| 表 | 说明 |
|----|------|
| `crm_clue` | 线索主表 |
| `crm_clue_follow` | 跟进记录 |
## 与 sx.sql 差异摘要
| 项 | sx.sql (CRM) | shanxia2.0 |
|----|--------------|------------|
| 主键 | `bigint` 自增 | `varchar(64)` UUID |
| 租户 | `tenant_id` | `tenant_no` |
| 删除 | 逻辑删字段各异 | 统一 `del_flag` |
| 公共字段 | 部分缺失 | `order_num, remark, create_by, create_dept_id, create_time, update_by, update_time, del_flag` |
业务字段名与 sx.sql **保持一致**(`clue_name`、`owner_user_id` 等)。
## 关联
- `crm_customer.clue_id`:客户表记录来源线索(转化时回写)
- 转化后 `crm_clue.customer_id` → 客户 `id`
## 增量脚本策略
| 场景 | 脚本 |
|------|------|
| 新环境建表 | 执行 `incremental_crm_clue.sql` |
| 已执行过旧版错误 DDL | 单独 diff 脚本(本模块暂无字段名漂移) |
| 菜单/字典 | 字典已在 `shanxia2.0.sql`;菜单见单独 `incremental_crm_clue_menu.sql`(可选) |
## 实施时注意
- 执行 DDL **先于** 后端联调
- 改表必须同步更新 `docs/sql/incremental_*.sql` 或全量导出
- 跑 `python scripts/check_field_consistency.py`(若扩展线索字段)