47 lines
2.4 KiB
Markdown
47 lines
2.4 KiB
Markdown
# DEVFLOW-1 CRUD 层实施
|
||
|
||
> 创建: 2026-06-10 | 状态: ✅ 已完成(2026-06-15 核对源码据实标注)
|
||
|
||
**完成简述**(核对 `crates/df-storage/src/`,非原计划文案):
|
||
|
||
- `crud.rs`:**13 个 Repo** = 12 个 `impl_repo!` 宏展开(IdeaRepo / ProjectRepo / TaskRepo / BranchRepo / ReleaseRepo / WorkflowRepo / NodeExecutionRepo / AiProviderRepo / AiToolExecutionRepo / AiConversationRepo / KnowledgeRepo / KnowledgeEventRepo)+ 1 个手写 `SettingsRepo`(KV,`app_settings` 表,不走宏)。
|
||
- `models.rs`:**12 个 `*Record` 结构体** 对应 12 张业务表。
|
||
- `migrations.rs`:**V1–V13 共 13 个迁移版本**,建 **14 张业务表**(ideas / projects / tasks / releases / workflow_executions / node_executions / branches / ai_conversations / knowledges / ai_providers / ai_tool_executions / knowledge_events / app_settings,另含 schema_version)。
|
||
- 事务支持:`crud.rs:701-711` 已用 `guard.transaction()` + `tx.commit()` 实现(如 `AiToolExecutionRepo` 原子写入)。
|
||
- 单元测试:`crud.rs` 含 **22 个 `#[test]` / `#[tokio::test]`**。
|
||
- 偏差说明:原计划列的 `workflow_defs`/`workflow_runs`/`artifacts` 表名在源码中实际为 `workflow_executions`/`node_executions`/`releases`(表名经设计调整),且实际多覆盖了 AI 对话 / 知识库 / AI Provider / KV 设置等领域,超出原计划范围。
|
||
|
||
---
|
||
|
||
## 概述
|
||
|
||
为 df-storage 实现完整的 CRUD 操作层,使所有 crate 能够持久化数据。这是 Phase 1 的首要任务,所有后续功能的前置条件。
|
||
|
||
## 目标
|
||
|
||
- [x] 定义泛型 `Repository<T>` trait(实际:以 `impl_repo!` 宏统一生成 insert/get_by_id/list_all/update_field/update_full/delete,配合手写 KV Repo)
|
||
- [x] 实现 ideas 表 CRUD
|
||
- [x] 实现 projects 表 CRUD
|
||
- [x] 实现 tasks 表 CRUD
|
||
- [x] 实现 workflow_defs 表 CRUD(实际表名 `workflow_executions`)
|
||
- [x] 实现 workflow_runs 表 CRUD(实际对应 `node_executions`)
|
||
- [x] 实现 artifacts 表 CRUD(实际对应 `releases`)
|
||
- [x] 事务支持(`crud.rs:701-711`)
|
||
- [x] 单元测试(22 个)
|
||
|
||
## 实施记录
|
||
|
||
原计划表名(`workflow_defs`/`workflow_runs`/`artifacts`)在落地时调整为 `workflow_executions`/`node_executions`/`releases`,见上方「完成简述」。CRUD 层已超出原计划覆盖 AI 对话、知识库、AI Provider、KV 设置等领域。
|
||
|
||
## 变更文件
|
||
|
||
*(待填写)*
|
||
|
||
## 遗留问题
|
||
|
||
*(待填写)*
|
||
|
||
## 下一步
|
||
|
||
*(待填写)*
|