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

59 lines
2.0 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 → 迁移后 DDL → 字段对照表」。
> **参考范例**:`docs/客户管理及公海池迁移方案.md` 第二章
> **规范约束**:`docs/crm-migration/ref-database-rules.md`
---
## X.1 crm_xxx([表说明])
### X.1.1 原始 DDL(来自 sx.sql)
```sql
-- 从 docs/sql/sx.sql 中复制该表的 CREATE TABLE 语句
```
### X.1.2 迁移后 DDL
```sql
DROP TABLE IF EXISTS `crm_xxx`;
CREATE TABLE `crm_xxx` (
-- 主键
`id` varchar(64) NOT NULL COMMENT '主键ID(UUID)',
-- 业务字段(与 sx.sql 业务字段一致,字段名/类型/默认值/枚举不变)
-- 公共字段(按标准顺序)
`tenant_no` varchar(64) NOT NULL DEFAULT 'shanxia2.0' COMMENT '租户编号',
`order_num` int(11) DEFAULT NULL COMMENT '排序号',
`remark` varchar(512) DEFAULT NULL COMMENT '备注',
`create_by` varchar(64) DEFAULT NULL COMMENT '创建人ID',
`create_dept_id` varchar(64) NOT NULL DEFAULT '' COMMENT '创建人部门ID',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_by` varchar(64) DEFAULT NULL COMMENT '更新人ID',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`del_flag` smallint(6) NOT NULL DEFAULT '0' COMMENT '删除标记(0存在 1删除)',
PRIMARY KEY (`id`)
-- 索引与原 CRM 等价
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='[表注释]';
```
### X.1.3 字段对照表
| # | 数据库字段 | API 字段(camelCase) | 类型 | 必填 | 默认值 | 说明 |
|---|-----------|---------------------|------|------|--------|------|
| 1 | id | id | string(UUID) | 自动 | generate_uuid() | 主键 |
| ... | ... | ... | ... | ... | ... | ... |
### X.1.4 字典关联
| 字段 | 字典类型(dict_type) | 字典值(与 sx.sql 一致) |
|------|----------------------|------------------------|
| ... | ... | ... |
---
<!-- 重复以上结构为每张表 -->