Some checks failed
App Prod-Parity E2E Dispatch / dispatch (push) Failing after 10s
CD Storybook UI / build (push) Failing after 3m25s
CD Storybook UI / dispatch (push) Has been skipped
CD deploy main / website-changed-files (push) Successful in 18m8s
CI Agent Skills / changed-files-check (push) Successful in 18m9s
CI Create App E2E minimal / changed-files-check (push) Successful in 24s
CI Create App / changed-files-check (push) Successful in 26s
CI Docs / changed-files-check (push) Successful in 26s
CI Emails / changed-files-check (push) Successful in 28s
CI Example App Hello World / changed-files-check (push) Successful in 23s
CI Front / changed-files-check (push) Has been skipped
CI Example App Postcard / changed-files-check (push) Successful in 27s
CI UI / changed-files-check (push) Has been skipped
CI Utils Test / changed-files-check (push) Successful in 45s
CI Twenty Apps / discover (push) Successful in 1m3s
CD deploy main / deploy-main (push) Failing after 3s
CI Agent Skills / agent-skills-validate (push) Has been skipped
CI Create App / create-app-test (lint) (push) Has been skipped
CI Emails / emails-test (push) Has been skipped
CI Front / front-task (lingui:compile) (push) Has been skipped
CI Front / front-task (lint) (push) Has been skipped
CI Example App Postcard / example-app-postcard (push) Has been skipped
CI UI / ui-task (lint) (push) Has been skipped
CI UI / ui-task (pack-size) (push) Has been skipped
CI UI / ui-task (size) (push) Has been skipped
CI UI / ui-task (test) (push) Has been skipped
CI UI / ui-task (typecheck) (push) Has been skipped
CI Utils Test / utils-test (push) Has been skipped
CI Twenty Apps / ${{ matrix.app.name }} (push) Has been skipped
CI Emails / ci-emails-status-check (push) Successful in 2s
CI Example App Hello World / ci-example-app-hello-world-status-check (push) Successful in 2s
CI Example App Postcard / ci-example-app-postcard-status-check (push) Successful in 3s
CI UI / ui-sb-test (push) Has been skipped
CI Utils Test / ci-utils-test-status-check (push) Successful in 2s
CI Twenty Apps / ci-twenty-apps-status-check (push) Successful in 2s
CI UI / ci-ui-status-check (push) Successful in 2s
CI Desktop / desktop (push) Failing after 1m8s
Push docs to Crowdin / Push documentation to Crowdin (push) Failing after 55s
Push translations to Crowdin / Extract and upload translations (push) Failing after 5s
Push website translations to Crowdin / Extract and upload website translations (push) Failing after 5s
CI Create App / create-app-test (test) (push) Has been skipped
CI Create App / create-app-test (typecheck) (push) Has been skipped
CI Docs / docs-lint (push) Has been skipped
CI Example App Hello World / example-app-hello-world (push) Has been skipped
CI Front / front-task (lingui:extract) (push) Has been skipped
CI Front / front-task (test) (push) Has been skipped
CI Front / front-task (typecheck) (push) Has been skipped
CI UI / ui-sb-build (push) Failing after 1m32s
CI Twenty Apps / ${{ matrix.app.name }} (${{ matrix.server-source }}) (push) Has been skipped
CI Agent Skills / agent-skills-publish (push) Has been skipped
CI Create App / ci-create-app-status-check (push) Successful in 2s
CI Agent Skills / agent-skills-remote-source (push) Has been skipped
CI Create App E2E minimal / create-app-e2e-minimal (push) Has been cancelled
CI E2E Main / e2e-test (push) Has been cancelled
CI Front / front-sb-build (push) Has been cancelled
CI Front / front-build (push) Has been cancelled
CI Create App E2E minimal / ci-create-app-e2e-minimal-status-check (push) Has been cancelled
CI E2E Main / ci-e2e-main-status-check (push) Has been cancelled
CI E2E Main / notify-main-ci-failure (push) Has been cancelled
CI E2E Main / qa-scout-comment (push) Has been cancelled
CI Front / front-sb-test (push) Has been cancelled
CI Front / front-sb-screenshots (push) Has been cancelled
CI Front / ci-front-status-check (push) Has been cancelled
DPA Sub-Processor Sync / sync-subprocessors (push) Failing after 3s
AI Catalog Sync / sync-catalog (push) Failing after 2s
73 lines
2.4 KiB
Plaintext
73 lines
2.4 KiB
Plaintext
---
|
||
title: 唯一性约束
|
||
description: Twenty 如何在导入过程中强制确保数据唯一性。
|
||
---
|
||
|
||
import { VimeoEmbed } from '/snippets/vimeo-embed.mdx';
|
||
|
||
## 概览
|
||
|
||
Twenty 会在特定字段上强制唯一性,以防止重复记录并确保数据完整性。 了解这些约束对于成功导入至关重要。
|
||
|
||
## 默认唯一字段
|
||
|
||
| 对象 | 唯一字段 |
|
||
| --------- | -------------- |
|
||
| **人员** | `id`, `email` |
|
||
| **公司** | `id`, `domain` |
|
||
| **自定义对象** | 仅 `id`(默认) |
|
||
|
||
<Note>`id` 字段是 Twenty 的内部标识符,为每条记录自动生成。 它使用 UUID 格式(例如,`c776ee49-f608-4a77-8cc8-6fe96ae1e43f`)。</Note>
|
||
|
||
## 自定义唯一字段
|
||
|
||
您可以在 **设置 → 数据模型** 下定义其他唯一字段:
|
||
|
||
1. 进入 **设置 → 数据模型**
|
||
2. 选择一个对象
|
||
3. 点击某个字段
|
||
4. 在字段设置中启用 **Unique**
|
||
|
||
### 自定义唯一字段的使用场景
|
||
|
||
* **外部 ID**:存储来自其他系统的 ID(Salesforce ID、HubSpot ID)
|
||
* **业务标识符**:员工编号、客户代码
|
||
* **替代联系方式**:LinkedIn 资料、电话号码
|
||
|
||
<Note>字段名 `id` 保留给 Twenty 的内部 ID。 外部标识符请使用 `externalId` 或 `legacyId` 等其他名称。</Note>
|
||
|
||
## 导入行为
|
||
|
||
### 创建新记录
|
||
|
||
如果唯一字段的值不存在,将创建一条新记录。
|
||
|
||
### 更新现有记录
|
||
|
||
如果唯一字段的值与现有记录匹配,该记录将使用新数据进行**更新**。
|
||
<Warning>要**更新现有记录**,建议**仅匹配一个唯一字段**。</Warning>
|
||
|
||
### 软删除的记录
|
||
|
||
<Warning>
|
||
**已删除的记录也会计入唯一性。**
|
||
|
||
软删除的记录(可在“命令菜单 → 查看已删除的记录”中查看)会包含在唯一性检查中。 如果您导入的记录与某条已删除记录具有相同的唯一值,该已删除记录将被**还原**,并使用新数据。
|
||
</Warning>
|
||
|
||
## 导入过程中的重复检测
|
||
|
||
在验证阶段:
|
||
|
||
* 文件中的重复项会以黄色高亮显示
|
||
* 开始导入前,您可以在界面中编辑或移除重复的行
|
||
|
||
<VimeoEmbed videoId="1145246326" title="视频演示" />
|
||
|
||
## 最佳实践
|
||
|
||
1. 在导入前,**从文件中移除重复项**
|
||
2. 在导入前,在 Twenty 中**检查是否存在现有记录**
|
||
3. 从其他系统迁移时,**使用外部 ID**
|
||
4. 如果您希望更新现有记录,请**包含唯一字段**
|