@allbluecn/database 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cf-env-stub.ts +4 -0
- package/cf-env.ts +25 -0
- package/cloudflare-workers.d.ts +6 -0
- package/desktop-init.ts +2 -2
- package/dist/cf-env-stub.d.ts +1 -0
- package/dist/cf-env-stub.js +4 -0
- package/dist/cf-env.d.ts +1 -0
- package/dist/cf-env.js +8 -0
- package/dist/lib/share-utils.js +3 -3
- package/generated/browser.ts +143 -38
- package/generated/client.ts +143 -38
- package/generated/commonInputTypes.ts +34 -0
- package/generated/enums.ts +14 -0
- package/generated/internal/class.ts +290 -80
- package/generated/internal/prismaNamespace.ts +3756 -1797
- package/generated/internal/prismaNamespaceBrowser.ts +478 -108
- package/generated/models/AgentConversation.ts +89 -89
- package/generated/models/AiProvider.ts +3 -3
- package/generated/models/AiStreamChunk.ts +3 -3
- package/generated/models/AiTask.ts +2481 -0
- package/generated/models/AiTaskRun.ts +1564 -0
- package/generated/models/AnyHubMarketApp.ts +8 -8
- package/generated/models/AuditLog.ts +6 -6
- package/generated/models/BlockInstance.ts +17 -17
- package/generated/models/Bug.ts +5116 -0
- package/generated/models/BugActivity.ts +1765 -0
- package/generated/models/BugComment.ts +1992 -0
- package/generated/models/BugCommentReaction.ts +1472 -0
- package/generated/models/BugEvent.ts +1339 -0
- package/generated/models/BugFilterView.ts +1438 -0
- package/generated/models/BugFixRun.ts +1479 -0
- package/generated/models/BugLabel.ts +1349 -0
- package/generated/models/BugProjectSettings.ts +1403 -0
- package/generated/models/BugReproRun.ts +1582 -0
- package/generated/models/ChatPersistenceMeta.ts +3 -3
- package/generated/models/CollabClient.ts +1199 -0
- package/generated/models/CollabDocument.ts +1121 -0
- package/generated/models/CollabUpdate.ts +1149 -0
- package/generated/models/Comment.ts +99 -99
- package/generated/models/Component.ts +7 -201
- package/generated/models/ComponentInstance.ts +17 -17
- package/generated/models/CustomRole.ts +8 -8
- package/generated/models/Design.ts +2682 -0
- package/generated/models/DesignPage.ts +2402 -0
- package/generated/models/DesignVersion.ts +2121 -0
- package/generated/models/DesktopSetting.ts +3 -3
- package/generated/models/Iteration.ts +148 -0
- package/generated/models/Label.ts +118 -0
- package/generated/models/LicenseKey.ts +16 -16
- package/generated/models/NotificationPreference.ts +5 -5
- package/generated/models/PageVersion.ts +49 -49
- package/generated/models/Plan.ts +5 -5
- package/generated/models/Project.ts +2240 -67
- package/generated/models/ProjectAccessToken.ts +1705 -0
- package/generated/models/ProjectWebhook.ts +1409 -0
- package/generated/models/Review.ts +118 -118
- package/generated/models/Share.ts +83 -83
- package/generated/models/ShareVersion.ts +15 -15
- package/generated/models/SsoProvider.ts +8 -8
- package/generated/models/Story.ts +973 -87
- package/generated/models/StoryDesignLink.ts +1430 -0
- package/generated/models/StoryFilterView.ts +12 -12
- package/generated/models/SystemPromptVersion.ts +6 -6
- package/generated/models/TestAutomationArtifact.ts +1790 -0
- package/generated/models/TestCase.ts +3645 -0
- package/generated/models/TestCaseFilterView.ts +1587 -0
- package/generated/models/TestCaseFolder.ts +1795 -0
- package/generated/models/TestExecRun.ts +1673 -0
- package/generated/models/TestGenerationRun.ts +1952 -0
- package/generated/models/TestPlan.ts +1950 -0
- package/generated/models/TestPlanCase.ts +1430 -0
- package/generated/models/TestRun.ts +1979 -0
- package/generated/models/TestRunCase.ts +2772 -0
- package/generated/models/ThirdPartyDependency.ts +19 -15
- package/generated/models/User.ts +13573 -3351
- package/generated/models/Workspace.ts +204 -0
- package/generated/models.ts +31 -10
- package/generated-sqlite/browser.ts +6 -36
- package/generated-sqlite/client.ts +6 -36
- package/generated-sqlite/internal/class.ts +16 -76
- package/generated-sqlite/internal/prismaNamespace.ts +127 -659
- package/generated-sqlite/internal/prismaNamespaceBrowser.ts +21 -103
- package/generated-sqlite/models/AgentConversation.ts +89 -89
- package/generated-sqlite/models/AiProvider.ts +3 -3
- package/generated-sqlite/models/AiStreamChunk.ts +3 -3
- package/generated-sqlite/models/AnyHubMarketApp.ts +8 -8
- package/generated-sqlite/models/BlockInstance.ts +17 -17
- package/generated-sqlite/models/ChatPersistenceMeta.ts +3 -3
- package/generated-sqlite/models/Comment.ts +99 -99
- package/generated-sqlite/models/Component.ts +7 -201
- package/generated-sqlite/models/ComponentInstance.ts +17 -17
- package/generated-sqlite/models/Design.ts +2497 -0
- package/generated-sqlite/models/DesignPage.ts +2398 -0
- package/generated-sqlite/models/DesignVersion.ts +2117 -0
- package/generated-sqlite/models/DesktopSetting.ts +3 -3
- package/generated-sqlite/models/KnowledgeBase.ts +240 -1
- package/generated-sqlite/models/NotificationPreference.ts +5 -5
- package/generated-sqlite/models/PageVersion.ts +49 -49
- package/generated-sqlite/models/Review.ts +118 -118
- package/generated-sqlite/models/Share.ts +83 -83
- package/generated-sqlite/models/ShareVersion.ts +15 -15
- package/generated-sqlite/models/SystemPromptVersion.ts +6 -6
- package/generated-sqlite/models/User.ts +1310 -2016
- package/generated-sqlite/models/Workspace.ts +164 -0
- package/generated-sqlite/models.ts +3 -9
- package/index.ts +31 -3
- package/migrations/20260924084200_add_prd_kind_drop_design_sketch/migration.sql +24 -0
- package/migrations/20260924123118_drop_user_sketch_api_token/migration.sql +8 -0
- package/migrations/20260925011516_rename_prd_tables/migration.sql +189 -0
- package/migrations/20260925064226_rename_prd_columns/migration.sql +193 -0
- package/migrations/20260925080000_rename_prd_embeddings/migration.sql +43 -0
- package/migrations/20261002184838_bug_module_init/migration.sql +297 -0
- package/migrations/20261004234209_testcase_module_init/migration.sql +290 -0
- package/migrations/20261005090000_testcase_plan_cases/migration.sql +34 -0
- package/migrations/20261006151229_add_missing_fk_indexes_auth_billing/migration.sql +50 -0
- package/migrations/20261006152058_add_missing_fk_indexes_story_bug_test/migration.sql +59 -0
- package/migrations/20261006152153_add_missing_fk_indexes_design_misc/migration.sql +50 -0
- package/migrations/20261006184250_explicit_on_delete_core/migration.sql +33 -0
- package/migrations/20261006184604_explicit_on_delete_rest/migration.sql +117 -0
- package/migrations/20261006184932_json_column_defaults/migration.sql +74 -0
- package/migrations/20261006191724_revert_version_token_cascade/migration.sql +21 -0
- package/migrations/20261007025537_dependency_category_enum/migration.sql +22 -0
- package/migrations/20261007112656_collab_init/migration.sql +45 -0
- package/migrations/20261007122530_collab_client_clientid_bigint/migration.sql +10 -0
- package/migrations/20261009194853_remove_tag_module/migration.sql +24 -0
- package/migrations/20261009222043_ai_task_init/migration.sql +67 -0
- package/migrations/20261019202531_ui_alignment_board_order/migration.sql +35 -0
- package/package.json +17 -6
- package/schema.prisma +777 -222
- package/schema.sqlite.prisma +140 -196
- package/src/lib/share-utils.ts +2 -2
- package/generated/models/Artboard.ts +0 -1811
- package/generated/models/ArtboardExport.ts +0 -1548
- package/generated/models/ComponentTag.ts +0 -1281
- package/generated/models/DesignProject.ts +0 -1643
- package/generated/models/PRD.ts +0 -2805
- package/generated/models/PRDPage.ts +0 -2402
- package/generated/models/PRDTag.ts +0 -1430
- package/generated/models/PRDVersion.ts +0 -2121
- package/generated/models/StoryPrdLink.ts +0 -1430
- package/generated/models/Tag.ts +0 -1655
- package/generated-sqlite/models/Artboard.ts +0 -1808
- package/generated-sqlite/models/ArtboardExport.ts +0 -1545
- package/generated-sqlite/models/ComponentTag.ts +0 -1278
- package/generated-sqlite/models/DesignProject.ts +0 -1640
- package/generated-sqlite/models/PRD.ts +0 -2616
- package/generated-sqlite/models/PRDPage.ts +0 -2398
- package/generated-sqlite/models/PRDTag.ts +0 -1426
- package/generated-sqlite/models/PRDVersion.ts +0 -2117
- package/generated-sqlite/models/Tag.ts +0 -1652
package/schema.prisma
CHANGED
|
@@ -37,7 +37,7 @@ model User {
|
|
|
37
37
|
|
|
38
38
|
accounts Account[]
|
|
39
39
|
|
|
40
|
-
avatarConfig Json?
|
|
40
|
+
avatarConfig Json? @default("{}")
|
|
41
41
|
bgShape String?
|
|
42
42
|
bgColor String?
|
|
43
43
|
|
|
@@ -49,8 +49,7 @@ model User {
|
|
|
49
49
|
|
|
50
50
|
storyDisplayOptions Json? // Story Display Options 个人偏好(URL 无参数时的默认值,跨设备持久化)
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
timezone String? // 用户全局时区,如 "Asia/Shanghai"。null = 浏览器时区
|
|
52
|
+
timezone String? // 用户全局时区,如 "Asia/Shanghai"。null = 浏览器时区
|
|
54
53
|
|
|
55
54
|
/// 用户偏好的计费币种(子项目 3 新增)
|
|
56
55
|
preferredCurrency String @default("usd")
|
|
@@ -63,8 +62,7 @@ model User {
|
|
|
63
62
|
passwordResetTokens PasswordResetToken[]
|
|
64
63
|
emailVerificationTokens EmailVerificationToken[]
|
|
65
64
|
emailPreference EmailPreference?
|
|
66
|
-
|
|
67
|
-
tags Tag[]
|
|
65
|
+
designs Design[]
|
|
68
66
|
knowledgeBases KnowledgeBase[]
|
|
69
67
|
knowledgeDocuments KnowledgeDocument[]
|
|
70
68
|
knowledgeShares KnowledgeShareRecord[]
|
|
@@ -78,12 +76,11 @@ model User {
|
|
|
78
76
|
anyhubMarketApps AnyHubMarketApp[]
|
|
79
77
|
reviewedAnyhubRecommendations AnyHubRecommendation[] @relation("reviewedAnyhubRecommendations")
|
|
80
78
|
anyhubRecommenders AnyHubRecommender[]
|
|
81
|
-
|
|
79
|
+
designVersions DesignVersion[]
|
|
82
80
|
reviewComments ReviewComment[]
|
|
83
81
|
comments Comment[]
|
|
84
82
|
commentIgnores CommentIgnore[]
|
|
85
83
|
reviews Review[] @relation("reviewer")
|
|
86
|
-
designProjects DesignProject[]
|
|
87
84
|
storiesCreated Story[] @relation("storyCreator")
|
|
88
85
|
storiesAssigned Story[] @relation("storyAssignee")
|
|
89
86
|
storiesEdited Story[] @relation("storyEditor")
|
|
@@ -123,8 +120,26 @@ model User {
|
|
|
123
120
|
harnessWorkspaces HarnessWorkspace[]
|
|
124
121
|
agentBindings BusinessAgentBinding[]
|
|
125
122
|
blobs Blob[]
|
|
123
|
+
bugsAssigned Bug[] @relation("bugAssignee")
|
|
124
|
+
bugsCreated Bug[] @relation("bugCreator")
|
|
125
|
+
bugsEdited Bug[] @relation("bugEditor")
|
|
126
|
+
bugActivities BugActivity[] @relation("bugActivityUser")
|
|
127
|
+
bugComments BugComment[] @relation("bugCommentUser")
|
|
128
|
+
bugCommentReactions BugCommentReaction[] @relation("bugCommentReactionUser")
|
|
129
|
+
bugReproRuns BugReproRun[] @relation("bugReproCreator")
|
|
130
|
+
projectAccessTokens ProjectAccessToken[] @relation("tokenCreator")
|
|
131
|
+
bugFilterViews BugFilterView[]
|
|
132
|
+
testCasesAssigned TestCase[] @relation("testCaseAssignee")
|
|
133
|
+
testCasesCreated TestCase[] @relation("testCaseCreator")
|
|
134
|
+
testGenerationRunsCreated TestGenerationRun[] @relation("testGenCreator")
|
|
135
|
+
testRunCasesExecuted TestRunCase[] @relation("testRunCaseExecutor")
|
|
136
|
+
testArtifactsCreated TestAutomationArtifact[] @relation("testArtifactCreator")
|
|
137
|
+
testCaseFilterViews TestCaseFilterView[]
|
|
138
|
+
aiTasksCreated AiTask[] @relation("aiTaskCreator")
|
|
126
139
|
|
|
127
140
|
@@map("users")
|
|
141
|
+
@@index([role])
|
|
142
|
+
@@index([status])
|
|
128
143
|
}
|
|
129
144
|
|
|
130
145
|
// OAuth 账号关联
|
|
@@ -158,7 +173,7 @@ model Project {
|
|
|
158
173
|
icon String @default("folder")
|
|
159
174
|
timezone String? // 项目时区,null = 跟随用户全局时区
|
|
160
175
|
ownerId String
|
|
161
|
-
owner User @relation("projectOwner", fields: [ownerId], references: [id])
|
|
176
|
+
owner User @relation("projectOwner", fields: [ownerId], references: [id], onDelete: Restrict)
|
|
162
177
|
workspaceId String?
|
|
163
178
|
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: SetNull)
|
|
164
179
|
members ProjectMember[]
|
|
@@ -167,6 +182,16 @@ model Project {
|
|
|
167
182
|
iterations Iteration[]
|
|
168
183
|
iterationAutoSchedule IterationAutoSchedule?
|
|
169
184
|
knowledgeBases ProjectKnowledgeBase[]
|
|
185
|
+
bugs Bug[]
|
|
186
|
+
accessTokens ProjectAccessToken[]
|
|
187
|
+
webhooks ProjectWebhook[]
|
|
188
|
+
aiTasks AiTask[]
|
|
189
|
+
bugSettings BugProjectSettings?
|
|
190
|
+
testCases TestCase[]
|
|
191
|
+
testCaseFolders TestCaseFolder[]
|
|
192
|
+
testGenerationRuns TestGenerationRun[]
|
|
193
|
+
testPlans TestPlan[]
|
|
194
|
+
testRuns TestRun[]
|
|
170
195
|
createdAt DateTime @default(now())
|
|
171
196
|
updatedAt DateTime @updatedAt
|
|
172
197
|
|
|
@@ -200,7 +225,7 @@ model Workspace {
|
|
|
200
225
|
description String?
|
|
201
226
|
pinnedToSidebar Boolean @default(false)
|
|
202
227
|
ownerId String
|
|
203
|
-
owner User @relation("workspaceOwner", fields: [ownerId], references: [id])
|
|
228
|
+
owner User @relation("workspaceOwner", fields: [ownerId], references: [id], onDelete: Restrict)
|
|
204
229
|
projects Project[]
|
|
205
230
|
members WorkspaceMember[]
|
|
206
231
|
knowledgeBases KnowledgeBase[]
|
|
@@ -214,6 +239,7 @@ model Workspace {
|
|
|
214
239
|
ssoProviders SsoProvider[]
|
|
215
240
|
customRoles CustomRole[]
|
|
216
241
|
auditLogs AuditLog[]
|
|
242
|
+
aiTasks AiTask[]
|
|
217
243
|
|
|
218
244
|
@@index([ownerId])
|
|
219
245
|
@@map("workspaces")
|
|
@@ -292,6 +318,7 @@ model TeamJoinRequest {
|
|
|
292
318
|
@@unique([invitationId, email])
|
|
293
319
|
@@index([ownerId, status])
|
|
294
320
|
@@map("team_join_requests")
|
|
321
|
+
@@index([userId])
|
|
295
322
|
}
|
|
296
323
|
|
|
297
324
|
// 项目活动记录
|
|
@@ -309,6 +336,7 @@ model ProjectActivity {
|
|
|
309
336
|
|
|
310
337
|
@@index([projectId, createdAt])
|
|
311
338
|
@@map("project_activities")
|
|
339
|
+
@@index([userId])
|
|
312
340
|
}
|
|
313
341
|
|
|
314
342
|
// 对话线程(作为 TanStack AI persistence threadId)
|
|
@@ -327,12 +355,14 @@ model ChatThread {
|
|
|
327
355
|
interrupts ChatInterrupt[]
|
|
328
356
|
generations GenerationRun[]
|
|
329
357
|
agentId String?
|
|
330
|
-
agent UserAgent? @relation(fields: [agentId], references: [id])
|
|
358
|
+
agent UserAgent? @relation(fields: [agentId], references: [id], onDelete: SetNull)
|
|
331
359
|
workspaceId String?
|
|
332
360
|
workspace HarnessWorkspace? @relation(fields: [workspaceId], references: [id], onDelete: SetNull)
|
|
333
361
|
|
|
334
362
|
@@index([userId, updatedAt])
|
|
335
363
|
@@map("chat_threads")
|
|
364
|
+
@@index([agentId])
|
|
365
|
+
@@index([workspaceId])
|
|
336
366
|
}
|
|
337
367
|
|
|
338
368
|
// 对话消息(TanStack AI messages store)
|
|
@@ -404,7 +434,7 @@ model ChatInterrupt {
|
|
|
404
434
|
model ChatPersistenceMeta {
|
|
405
435
|
namespace String
|
|
406
436
|
key String
|
|
407
|
-
value Json
|
|
437
|
+
value Json @default("{}")
|
|
408
438
|
updatedAt DateTime @updatedAt
|
|
409
439
|
|
|
410
440
|
@@unique([namespace, key])
|
|
@@ -463,7 +493,7 @@ model SystemPromptVersion {
|
|
|
463
493
|
templateId String
|
|
464
494
|
template SystemPromptTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
|
465
495
|
version Int
|
|
466
|
-
sections Json
|
|
496
|
+
sections Json @default("[]")
|
|
467
497
|
note String?
|
|
468
498
|
createdBy String?
|
|
469
499
|
createdAt DateTime @default(now())
|
|
@@ -491,6 +521,7 @@ model BusinessAgentBinding {
|
|
|
491
521
|
@@unique([userId, bizKey])
|
|
492
522
|
@@index([userId])
|
|
493
523
|
@@map("business_agent_bindings")
|
|
524
|
+
@@index([agentId])
|
|
494
525
|
}
|
|
495
526
|
|
|
496
527
|
// 媒体生成记录(占位,本轮建表不接入业务)
|
|
@@ -534,6 +565,8 @@ model LoginLog {
|
|
|
534
565
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
535
566
|
|
|
536
567
|
@@map("login_logs")
|
|
568
|
+
@@index([userId])
|
|
569
|
+
@@index([createdAt])
|
|
537
570
|
}
|
|
538
571
|
|
|
539
572
|
// 邀请码
|
|
@@ -544,6 +577,10 @@ model InvitationCode {
|
|
|
544
577
|
usedCount Int @default(0)
|
|
545
578
|
expiresAt DateTime
|
|
546
579
|
createdAt DateTime @default(now())
|
|
580
|
+
// DB-13 决策:保留不删、暂不加 FK。原判「悬空列」不实——admin invitations
|
|
581
|
+
// 写入 createdById(session.user.id)并按 id 联表展示创建者,删除前置条件
|
|
582
|
+
// 「0 引用」不成立;存量数据未清洗,直接加 FK 有约束创建失败风险。
|
|
583
|
+
// 后续任务:回填清洗(孤儿置 null)→ 加 relation + SetNull + 索引。
|
|
547
584
|
createdById String?
|
|
548
585
|
disabledAt DateTime?
|
|
549
586
|
|
|
@@ -563,6 +600,8 @@ model InvitationUse {
|
|
|
563
600
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
564
601
|
|
|
565
602
|
@@map("invitation_uses")
|
|
603
|
+
@@index([codeId])
|
|
604
|
+
@@index([userId])
|
|
566
605
|
}
|
|
567
606
|
|
|
568
607
|
// 密码重置令牌
|
|
@@ -577,6 +616,7 @@ model PasswordResetToken {
|
|
|
577
616
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
578
617
|
|
|
579
618
|
@@map("password_reset_tokens")
|
|
619
|
+
@@index([userId])
|
|
580
620
|
}
|
|
581
621
|
|
|
582
622
|
// 邮箱验证令牌
|
|
@@ -591,6 +631,7 @@ model EmailVerificationToken {
|
|
|
591
631
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
592
632
|
|
|
593
633
|
@@map("email_verification_tokens")
|
|
634
|
+
@@index([userId])
|
|
594
635
|
}
|
|
595
636
|
|
|
596
637
|
// 出站邮件日志
|
|
@@ -745,15 +786,17 @@ model KnowledgeDocument {
|
|
|
745
786
|
@@index([parentId])
|
|
746
787
|
@@index([kbId, isHomepage])
|
|
747
788
|
@@map("knowledge_documents")
|
|
789
|
+
@@index([createdBy])
|
|
748
790
|
}
|
|
749
791
|
|
|
750
|
-
//
|
|
751
|
-
model
|
|
792
|
+
// Design 文档表
|
|
793
|
+
model Design {
|
|
752
794
|
id String @id @default(cuid())
|
|
753
795
|
icon String @default("file") // 图标名称
|
|
754
|
-
name String //
|
|
796
|
+
name String // Design 名称
|
|
755
797
|
description String? // 介绍
|
|
756
|
-
|
|
798
|
+
kind String @default("doc") // 板块合并:doc=文档型,canvas=画板型
|
|
799
|
+
settings Json? @default("{}") // 文档设置(布局、主题等)
|
|
757
800
|
userId String // 所属用户
|
|
758
801
|
isDeleted Boolean @default(false)
|
|
759
802
|
deletedAt DateTime?
|
|
@@ -761,33 +804,32 @@ model PRD {
|
|
|
761
804
|
updatedAt DateTime @updatedAt
|
|
762
805
|
|
|
763
806
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
764
|
-
pages
|
|
765
|
-
versions
|
|
807
|
+
pages DesignPage[]
|
|
808
|
+
versions DesignVersion[]
|
|
766
809
|
reviews Review[]
|
|
767
810
|
comments Comment[]
|
|
768
811
|
shares Share[]
|
|
769
|
-
prdTags PRDTag[]
|
|
770
812
|
agentConversations AgentConversation[]
|
|
771
|
-
linkedStories
|
|
813
|
+
linkedStories StoryDesignLink[] @relation("DesignStoryLinks")
|
|
772
814
|
|
|
773
815
|
@@index([userId])
|
|
774
|
-
@@map("
|
|
816
|
+
@@map("designs")
|
|
775
817
|
}
|
|
776
818
|
|
|
777
819
|
// Agent 原型生成会话
|
|
778
820
|
model AgentConversation {
|
|
779
821
|
id String @id @default(cuid())
|
|
780
822
|
userId String
|
|
781
|
-
|
|
823
|
+
designId String
|
|
782
824
|
title String @default("新会话")
|
|
783
825
|
createdAt DateTime @default(now())
|
|
784
826
|
updatedAt DateTime @updatedAt
|
|
785
827
|
|
|
786
828
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
787
|
-
|
|
829
|
+
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
788
830
|
messages AgentMessage[]
|
|
789
831
|
|
|
790
|
-
@@index([userId,
|
|
832
|
+
@@index([userId, designId])
|
|
791
833
|
@@map("agent_conversations")
|
|
792
834
|
}
|
|
793
835
|
|
|
@@ -819,7 +861,7 @@ model Component {
|
|
|
819
861
|
defaultWidth Int @default(200)
|
|
820
862
|
defaultHeight Int @default(40)
|
|
821
863
|
prototypeKey String? // unique key for registry lookup (e.g. "text", "button")
|
|
822
|
-
config Json // 属性描述 schema(props定义、slots、events)
|
|
864
|
+
config Json @default("{}") // 属性描述 schema(props定义、slots、events)
|
|
823
865
|
defaultProps Json? // 默认属性值
|
|
824
866
|
defaultStyle Json? // 默认样式
|
|
825
867
|
preview String? // 预览图URL
|
|
@@ -834,7 +876,6 @@ model Component {
|
|
|
834
876
|
|
|
835
877
|
blockItems BlockComponent[] @relation("componentRef")
|
|
836
878
|
instances ComponentInstance[] @relation("componentRef")
|
|
837
|
-
componentTags ComponentTag[]
|
|
838
879
|
tags String[] @default([])
|
|
839
880
|
|
|
840
881
|
@@index([type, category])
|
|
@@ -876,9 +917,11 @@ model BlockComponent {
|
|
|
876
917
|
styleOverride Json? // 局部覆写样式
|
|
877
918
|
|
|
878
919
|
block Block @relation(fields: [blockId], references: [id], onDelete: Cascade)
|
|
879
|
-
component Component @relation("componentRef", fields: [componentId], references: [id])
|
|
920
|
+
component Component @relation("componentRef", fields: [componentId], references: [id], onDelete: Cascade)
|
|
880
921
|
|
|
881
922
|
@@map("block_components")
|
|
923
|
+
@@index([blockId])
|
|
924
|
+
@@index([componentId])
|
|
882
925
|
}
|
|
883
926
|
|
|
884
927
|
// 模板定义表(后台维护)
|
|
@@ -909,34 +952,37 @@ model TemplateBlock {
|
|
|
909
952
|
height Float?
|
|
910
953
|
|
|
911
954
|
template Template @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
|
912
|
-
block Block @relation("templateBlockRef", fields: [blockId], references: [id])
|
|
955
|
+
block Block @relation("templateBlockRef", fields: [blockId], references: [id], onDelete: Cascade)
|
|
913
956
|
|
|
914
957
|
@@map("template_blocks")
|
|
958
|
+
@@index([templateId])
|
|
959
|
+
@@index([blockId])
|
|
915
960
|
}
|
|
916
961
|
|
|
917
|
-
//
|
|
918
|
-
model
|
|
962
|
+
// Design 页面/目录树节点
|
|
963
|
+
model DesignPage {
|
|
919
964
|
id String @id @default(cuid())
|
|
920
|
-
|
|
965
|
+
designId String
|
|
921
966
|
parentId String? // 父节点,构建树形结构(null = 根级)
|
|
922
967
|
name String
|
|
923
968
|
order Int @default(0) // 排序
|
|
924
969
|
type String @default("page") // "page" | "folder"
|
|
925
970
|
canvas Json? // 原型画板数据
|
|
926
|
-
content Json? //
|
|
971
|
+
content Json? // Design 文档内容
|
|
927
972
|
version Int @default(1) // 页面版本号
|
|
928
973
|
createdAt DateTime @default(now())
|
|
929
974
|
updatedAt DateTime @updatedAt
|
|
930
975
|
|
|
931
|
-
|
|
932
|
-
parent
|
|
933
|
-
children
|
|
976
|
+
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
977
|
+
parent DesignPage? @relation("PageHierarchy", fields: [parentId], references: [id], onDelete: Cascade)
|
|
978
|
+
children DesignPage[] @relation("PageHierarchy")
|
|
934
979
|
componentInstances ComponentInstance[]
|
|
935
980
|
blockInstances BlockInstance[]
|
|
936
981
|
pageVersions PageVersion[]
|
|
937
982
|
|
|
938
|
-
@@index([
|
|
939
|
-
@@map("
|
|
983
|
+
@@index([designId, order])
|
|
984
|
+
@@map("design_pages")
|
|
985
|
+
@@index([parentId])
|
|
940
986
|
}
|
|
941
987
|
|
|
942
988
|
// 组件实例(画布上)
|
|
@@ -956,12 +1002,14 @@ model ComponentInstance {
|
|
|
956
1002
|
createdAt DateTime @default(now())
|
|
957
1003
|
updatedAt DateTime @updatedAt
|
|
958
1004
|
|
|
959
|
-
page
|
|
960
|
-
component Component? @relation("componentRef", fields: [componentId], references: [id])
|
|
961
|
-
blockInstance BlockInstance? @relation(fields: [blockInstanceId], references: [id])
|
|
1005
|
+
page DesignPage @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
|
1006
|
+
component Component? @relation("componentRef", fields: [componentId], references: [id], onDelete: SetNull)
|
|
1007
|
+
blockInstance BlockInstance? @relation(fields: [blockInstanceId], references: [id], onDelete: SetNull)
|
|
962
1008
|
|
|
963
1009
|
@@index([pageId])
|
|
964
1010
|
@@map("component_instances")
|
|
1011
|
+
@@index([componentId])
|
|
1012
|
+
@@index([blockInstanceId])
|
|
965
1013
|
}
|
|
966
1014
|
|
|
967
1015
|
// 区块实例(画布上)
|
|
@@ -980,37 +1028,40 @@ model BlockInstance {
|
|
|
980
1028
|
createdAt DateTime @default(now())
|
|
981
1029
|
updatedAt DateTime @updatedAt
|
|
982
1030
|
|
|
983
|
-
page
|
|
984
|
-
block Block? @relation("blockRef", fields: [blockId], references: [id])
|
|
1031
|
+
page DesignPage @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
|
1032
|
+
block Block? @relation("blockRef", fields: [blockId], references: [id], onDelete: SetNull)
|
|
985
1033
|
instances ComponentInstance[]
|
|
986
1034
|
|
|
987
1035
|
@@index([pageId])
|
|
988
1036
|
@@map("block_instances")
|
|
1037
|
+
@@index([blockId])
|
|
989
1038
|
}
|
|
990
1039
|
|
|
991
|
-
//
|
|
992
|
-
model
|
|
1040
|
+
// Design 版本(手动发布创建)
|
|
1041
|
+
model DesignVersion {
|
|
993
1042
|
id String @id @default(cuid())
|
|
994
|
-
|
|
1043
|
+
designId String
|
|
995
1044
|
major Int @default(1)
|
|
996
1045
|
minor Int @default(0)
|
|
997
1046
|
patch Int @default(0)
|
|
998
1047
|
versionLabel String // 如 "v1", "v1.1", "v1.1.1"
|
|
999
1048
|
parentVersion String? // 上一版本ID(版本链)
|
|
1000
|
-
pageVersions Json // [{ pageId, pageName, version, canvas, content }]
|
|
1049
|
+
pageVersions Json @default("[]") // [{ pageId, pageName, version, canvas, content }]
|
|
1001
1050
|
notes String? // 发版说明
|
|
1002
1051
|
userId String
|
|
1003
1052
|
createdAt DateTime @default(now())
|
|
1004
1053
|
updatedAt DateTime?
|
|
1005
1054
|
|
|
1006
|
-
|
|
1007
|
-
|
|
1055
|
+
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
1056
|
+
// 产品决策(审查修复):Restrict——版本归属共享 Design 而非创建者个人,删创建者
|
|
1057
|
+
// 级联删版本会经 Review.version/ReviewComment/ShareVersion 销毁他人数据。
|
|
1058
|
+
user User @relation(fields: [userId], references: [id], onDelete: Restrict)
|
|
1008
1059
|
reviews Review[]
|
|
1009
1060
|
shareVersions ShareVersion[]
|
|
1010
1061
|
|
|
1011
|
-
@@index([
|
|
1062
|
+
@@index([designId, createdAt])
|
|
1012
1063
|
@@index([userId])
|
|
1013
|
-
@@map("
|
|
1064
|
+
@@map("design_versions")
|
|
1014
1065
|
}
|
|
1015
1066
|
|
|
1016
1067
|
// 页面版本(独立的页面级别版本历史)
|
|
@@ -1019,13 +1070,13 @@ model PageVersion {
|
|
|
1019
1070
|
pageId String
|
|
1020
1071
|
version Int // 整数版本号,自增
|
|
1021
1072
|
notes String? // 版本说明(用户可编辑)
|
|
1022
|
-
canvas Json? // 原型快照
|
|
1073
|
+
canvas Json? @default("{}") // 原型快照
|
|
1023
1074
|
content Json? // 文档快照
|
|
1024
1075
|
restoredFromVersion Int? // 从哪个版本号还原而来(null 表示非还原版本)
|
|
1025
|
-
|
|
1076
|
+
fromDesignVersionId String? // 来源:从哪个 Design 版本创建(可选标记)
|
|
1026
1077
|
createdAt DateTime @default(now())
|
|
1027
1078
|
|
|
1028
|
-
page
|
|
1079
|
+
page DesignPage @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
|
1029
1080
|
|
|
1030
1081
|
@@index([pageId, createdAt])
|
|
1031
1082
|
@@index([pageId, version])
|
|
@@ -1035,7 +1086,7 @@ model PageVersion {
|
|
|
1035
1086
|
// 评审工作流
|
|
1036
1087
|
model Review {
|
|
1037
1088
|
id String @id @default(cuid())
|
|
1038
|
-
|
|
1089
|
+
designId String
|
|
1039
1090
|
versionId String
|
|
1040
1091
|
status ReviewStatus @default(PENDING)
|
|
1041
1092
|
reviewerId String?
|
|
@@ -1043,13 +1094,13 @@ model Review {
|
|
|
1043
1094
|
createdAt DateTime @default(now())
|
|
1044
1095
|
completedAt DateTime?
|
|
1045
1096
|
|
|
1046
|
-
|
|
1047
|
-
version
|
|
1048
|
-
reviewer User? @relation("reviewer", fields: [reviewerId], references: [id])
|
|
1097
|
+
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
1098
|
+
version DesignVersion @relation(fields: [versionId], references: [id], onDelete: Cascade)
|
|
1099
|
+
reviewer User? @relation("reviewer", fields: [reviewerId], references: [id], onDelete: SetNull)
|
|
1049
1100
|
comments ReviewComment[]
|
|
1050
1101
|
|
|
1051
|
-
@@unique([
|
|
1052
|
-
@@index([
|
|
1102
|
+
@@unique([designId, versionId])
|
|
1103
|
+
@@index([designId])
|
|
1053
1104
|
@@index([versionId])
|
|
1054
1105
|
@@index([reviewerId])
|
|
1055
1106
|
@@map("reviews")
|
|
@@ -1067,8 +1118,8 @@ model ReviewComment {
|
|
|
1067
1118
|
createdAt DateTime @default(now())
|
|
1068
1119
|
|
|
1069
1120
|
review Review @relation(fields: [reviewId], references: [id], onDelete: Cascade)
|
|
1070
|
-
user User @relation(fields: [userId], references: [id])
|
|
1071
|
-
parent ReviewComment? @relation("ReviewCommentReplies", fields: [parentId], references: [id])
|
|
1121
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1122
|
+
parent ReviewComment? @relation("ReviewCommentReplies", fields: [parentId], references: [id], onDelete: SetNull)
|
|
1072
1123
|
replies ReviewComment[] @relation("ReviewCommentReplies")
|
|
1073
1124
|
|
|
1074
1125
|
@@index([reviewId])
|
|
@@ -1077,10 +1128,10 @@ model ReviewComment {
|
|
|
1077
1128
|
@@map("review_comments")
|
|
1078
1129
|
}
|
|
1079
1130
|
|
|
1080
|
-
// 评论(
|
|
1131
|
+
// 评论(Design 级别 / 页面级别 / 元素级别)
|
|
1081
1132
|
model Comment {
|
|
1082
1133
|
id String @id @default(cuid())
|
|
1083
|
-
|
|
1134
|
+
designId String
|
|
1084
1135
|
pageId String? // 可选:针对某页面
|
|
1085
1136
|
elementId String? // 可选:针对某元素(组件/区块实例ID)
|
|
1086
1137
|
userId String
|
|
@@ -1091,13 +1142,13 @@ model Comment {
|
|
|
1091
1142
|
createdAt DateTime @default(now())
|
|
1092
1143
|
updatedAt DateTime @updatedAt
|
|
1093
1144
|
|
|
1094
|
-
|
|
1095
|
-
user User @relation(fields: [userId], references: [id])
|
|
1096
|
-
parent Comment? @relation("CommentReplies", fields: [parentId], references: [id])
|
|
1145
|
+
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
1146
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1147
|
+
parent Comment? @relation("CommentReplies", fields: [parentId], references: [id], onDelete: SetNull)
|
|
1097
1148
|
replies Comment[] @relation("CommentReplies")
|
|
1098
1149
|
ignores CommentIgnore[]
|
|
1099
1150
|
|
|
1100
|
-
@@index([
|
|
1151
|
+
@@index([designId])
|
|
1101
1152
|
@@index([userId])
|
|
1102
1153
|
@@index([parentId])
|
|
1103
1154
|
@@index([pageId])
|
|
@@ -1110,8 +1161,8 @@ model CommentIgnore {
|
|
|
1110
1161
|
commentId String
|
|
1111
1162
|
createdAt DateTime @default(now())
|
|
1112
1163
|
|
|
1113
|
-
user User @relation(fields: [userId], references: [id])
|
|
1114
|
-
comment Comment @relation(fields: [commentId], references: [id])
|
|
1164
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1165
|
+
comment Comment @relation(fields: [commentId], references: [id], onDelete: Cascade)
|
|
1115
1166
|
|
|
1116
1167
|
@@unique([userId, commentId])
|
|
1117
1168
|
@@index([userId])
|
|
@@ -1122,7 +1173,7 @@ model CommentIgnore {
|
|
|
1122
1173
|
// 分享链接
|
|
1123
1174
|
model Share {
|
|
1124
1175
|
id String @id @default(cuid())
|
|
1125
|
-
|
|
1176
|
+
designId String
|
|
1126
1177
|
token String @unique
|
|
1127
1178
|
type String @default("prd") // "prd" | 预留扩展
|
|
1128
1179
|
status ShareStatus @default(ACTIVE)
|
|
@@ -1132,67 +1183,16 @@ model Share {
|
|
|
1132
1183
|
createdAt DateTime @default(now())
|
|
1133
1184
|
updatedAt DateTime @updatedAt
|
|
1134
1185
|
|
|
1135
|
-
|
|
1186
|
+
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
1136
1187
|
shareVersions ShareVersion[]
|
|
1137
1188
|
|
|
1138
1189
|
@@index([token])
|
|
1139
|
-
@@index([
|
|
1190
|
+
@@index([designId, type, status])
|
|
1140
1191
|
@@index([status])
|
|
1141
1192
|
@@index([expiresAt])
|
|
1142
1193
|
@@map("shares")
|
|
1143
1194
|
}
|
|
1144
1195
|
|
|
1145
|
-
// 标签表
|
|
1146
|
-
model Tag {
|
|
1147
|
-
id String @id @default(cuid())
|
|
1148
|
-
name String
|
|
1149
|
-
color Int @default(0)
|
|
1150
|
-
sortOrder Int @default(0)
|
|
1151
|
-
isHidden Boolean @default(false)
|
|
1152
|
-
userId String
|
|
1153
|
-
createdAt DateTime @default(now())
|
|
1154
|
-
updatedAt DateTime @updatedAt
|
|
1155
|
-
|
|
1156
|
-
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1157
|
-
prdTags PRDTag[]
|
|
1158
|
-
|
|
1159
|
-
@@unique([name, userId])
|
|
1160
|
-
@@index([sortOrder])
|
|
1161
|
-
@@index([userId])
|
|
1162
|
-
@@map("tags")
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
// PRD-标签多对多
|
|
1166
|
-
model PRDTag {
|
|
1167
|
-
id String @id @default(cuid())
|
|
1168
|
-
prdId String
|
|
1169
|
-
tagId String
|
|
1170
|
-
createdAt DateTime @default(now())
|
|
1171
|
-
|
|
1172
|
-
prd PRD @relation(fields: [prdId], references: [id], onDelete: Cascade)
|
|
1173
|
-
tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
|
|
1174
|
-
|
|
1175
|
-
@@unique([prdId, tagId])
|
|
1176
|
-
@@index([prdId])
|
|
1177
|
-
@@index([tagId])
|
|
1178
|
-
@@map("prd_tags")
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
// 组件-标签多对多
|
|
1182
|
-
// TODO(ComponentTag 重新调整): Tag 已加 userId,ComponentTag 业务待后续调整。
|
|
1183
|
-
// DB 端 FK 已 drop(迁移同步);component_tags 表保留,tagId 列 + 唯一约束 (componentId, tagId) 保留;
|
|
1184
|
-
// 移除 Prisma 关系以避免与新 Tag 语义冲突。
|
|
1185
|
-
model ComponentTag {
|
|
1186
|
-
id String @id @default(cuid())
|
|
1187
|
-
componentId String
|
|
1188
|
-
tagId String
|
|
1189
|
-
|
|
1190
|
-
component Component @relation(fields: [componentId], references: [id], onDelete: Cascade)
|
|
1191
|
-
|
|
1192
|
-
@@unique([componentId, tagId])
|
|
1193
|
-
@@map("component_tags")
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
1196
|
model Reference {
|
|
1197
1197
|
id String @id @default(uuid())
|
|
1198
1198
|
sourceModule String
|
|
@@ -1212,7 +1212,7 @@ model ShareVersion {
|
|
|
1212
1212
|
versionId String
|
|
1213
1213
|
|
|
1214
1214
|
share Share @relation(fields: [shareId], references: [id], onDelete: Cascade)
|
|
1215
|
-
version
|
|
1215
|
+
version DesignVersion @relation(fields: [versionId], references: [id], onDelete: Cascade)
|
|
1216
1216
|
|
|
1217
1217
|
@@unique([shareId, versionId])
|
|
1218
1218
|
@@index([shareId])
|
|
@@ -1274,7 +1274,7 @@ model AnyHubMarketApp {
|
|
|
1274
1274
|
category String?
|
|
1275
1275
|
tags String? @db.Text
|
|
1276
1276
|
downloads Int @default(0)
|
|
1277
|
-
capabilities Json
|
|
1277
|
+
capabilities Json @default("{}")
|
|
1278
1278
|
status MarketplaceAppStatus @default(DRAFT)
|
|
1279
1279
|
publishedAt DateTime?
|
|
1280
1280
|
userId String
|
|
@@ -1282,11 +1282,12 @@ model AnyHubMarketApp {
|
|
|
1282
1282
|
createdAt DateTime @default(now())
|
|
1283
1283
|
updatedAt DateTime @updatedAt
|
|
1284
1284
|
|
|
1285
|
-
user User @relation(fields: [userId], references: [id])
|
|
1286
|
-
recommendation AnyHubRecommendation? @relation("anyhubRecommendation", fields: [recommendationId], references: [id])
|
|
1285
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1286
|
+
recommendation AnyHubRecommendation? @relation("anyhubRecommendation", fields: [recommendationId], references: [id], onDelete: SetNull)
|
|
1287
1287
|
|
|
1288
1288
|
@@index([status])
|
|
1289
1289
|
@@index([category])
|
|
1290
|
+
@@index([userId])
|
|
1290
1291
|
}
|
|
1291
1292
|
|
|
1292
1293
|
model AnyHubRecommendation {
|
|
@@ -1303,10 +1304,11 @@ model AnyHubRecommendation {
|
|
|
1303
1304
|
updatedAt DateTime @updatedAt
|
|
1304
1305
|
|
|
1305
1306
|
marketplaceApp AnyHubMarketApp? @relation("anyhubRecommendation")
|
|
1306
|
-
reviewer User? @relation("reviewedAnyhubRecommendations", fields: [reviewedBy], references: [id])
|
|
1307
|
+
reviewer User? @relation("reviewedAnyhubRecommendations", fields: [reviewedBy], references: [id], onDelete: SetNull)
|
|
1307
1308
|
recommenders AnyHubRecommender[]
|
|
1308
1309
|
|
|
1309
1310
|
@@index([status])
|
|
1311
|
+
@@index([reviewedBy])
|
|
1310
1312
|
}
|
|
1311
1313
|
|
|
1312
1314
|
model AnyHubRecommender {
|
|
@@ -1323,58 +1325,6 @@ model AnyHubRecommender {
|
|
|
1323
1325
|
}
|
|
1324
1326
|
|
|
1325
1327
|
// 设计稿
|
|
1326
|
-
model DesignProject {
|
|
1327
|
-
id String @id @default(cuid())
|
|
1328
|
-
name String
|
|
1329
|
-
documentId String?
|
|
1330
|
-
sketchName String?
|
|
1331
|
-
version Int @default(1)
|
|
1332
|
-
userId String
|
|
1333
|
-
user User @relation(fields: [userId], references: [id])
|
|
1334
|
-
artboards Artboard[]
|
|
1335
|
-
createdAt DateTime @default(now())
|
|
1336
|
-
updatedAt DateTime @updatedAt
|
|
1337
|
-
|
|
1338
|
-
@@index([userId])
|
|
1339
|
-
@@map("design_projects")
|
|
1340
|
-
}
|
|
1341
|
-
|
|
1342
|
-
model Artboard {
|
|
1343
|
-
id String @id @default(cuid())
|
|
1344
|
-
projectId String
|
|
1345
|
-
project DesignProject @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
1346
|
-
name String
|
|
1347
|
-
pageName String?
|
|
1348
|
-
width Int
|
|
1349
|
-
height Int
|
|
1350
|
-
pngPath String
|
|
1351
|
-
svgPath String?
|
|
1352
|
-
annotationJson Json?
|
|
1353
|
-
layerCount Int?
|
|
1354
|
-
sortOrder Int @default(0)
|
|
1355
|
-
createdAt DateTime @default(now())
|
|
1356
|
-
exports ArtboardExport[]
|
|
1357
|
-
|
|
1358
|
-
@@index([projectId])
|
|
1359
|
-
@@map("design_artboards")
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
model ArtboardExport {
|
|
1363
|
-
id String @id @default(cuid())
|
|
1364
|
-
artboardId String
|
|
1365
|
-
artboard Artboard @relation(fields: [artboardId], references: [id], onDelete: Cascade)
|
|
1366
|
-
layerName String
|
|
1367
|
-
layerId String
|
|
1368
|
-
scale Int
|
|
1369
|
-
format String @default("png")
|
|
1370
|
-
filePath String
|
|
1371
|
-
width Int
|
|
1372
|
-
height Int
|
|
1373
|
-
|
|
1374
|
-
@@unique([artboardId, layerId, scale])
|
|
1375
|
-
@@map("design_artboard_exports")
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
1328
|
// AI 服务商元数据(admin 维护)
|
|
1379
1329
|
model AiProvider {
|
|
1380
1330
|
id String @id @default(cuid())
|
|
@@ -1393,7 +1343,7 @@ model AiProvider {
|
|
|
1393
1343
|
badge String? // 卡片角标文案(如「推荐」「热门」「NEW」),admin 可配
|
|
1394
1344
|
isLocal Boolean @default(false)
|
|
1395
1345
|
enabled Boolean @default(true) // 平台级开关:停用后未配置用户看不到,已配置用户继续可用
|
|
1396
|
-
models Json // AiModelMeta[](admin 可编辑)
|
|
1346
|
+
models Json @default("[]") // AiModelMeta[](admin 可编辑)
|
|
1397
1347
|
sortOrder Int @default(0)
|
|
1398
1348
|
createdAt DateTime @default(now())
|
|
1399
1349
|
updatedAt DateTime @updatedAt
|
|
@@ -1433,7 +1383,7 @@ model ThirdPartyDependency {
|
|
|
1433
1383
|
displayName String? // 展示名(默认取 name)
|
|
1434
1384
|
description String? @db.Text // 依赖用途说明(admin 可编辑)
|
|
1435
1385
|
homepage String? // 官网 / 仓库
|
|
1436
|
-
category
|
|
1386
|
+
category DependencyCategory @default(other) // 值集与 kernel DependencyCategory 对齐(含 auth)
|
|
1437
1387
|
isWatched Boolean @default(true) // 是否置顶「关注列表」
|
|
1438
1388
|
priority String @default("normal") // high|normal|low
|
|
1439
1389
|
latestVersion String? // 缓存的 npm registry latest 版本
|
|
@@ -1629,13 +1579,16 @@ model Story {
|
|
|
1629
1579
|
startDate DateTime?
|
|
1630
1580
|
targetDate DateTime?
|
|
1631
1581
|
createdById String
|
|
1632
|
-
createdBy User @relation("storyCreator", fields: [createdById], references: [id])
|
|
1582
|
+
createdBy User @relation("storyCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
1633
1583
|
updatedById String?
|
|
1634
1584
|
updatedBy User? @relation("storyEditor", fields: [updatedById], references: [id], onDelete: SetNull)
|
|
1635
1585
|
labels StoryLabel[]
|
|
1636
1586
|
activities StoryActivity[]
|
|
1637
1587
|
comments StoryComment[]
|
|
1638
1588
|
reactions StoryReaction[]
|
|
1589
|
+
bugs Bug[]
|
|
1590
|
+
testCases TestCase[]
|
|
1591
|
+
generationRuns TestGenerationRun[]
|
|
1639
1592
|
createdAt DateTime @default(now())
|
|
1640
1593
|
updatedAt DateTime @updatedAt
|
|
1641
1594
|
|
|
@@ -1646,7 +1599,7 @@ model Story {
|
|
|
1646
1599
|
dependenciesAsTarget StoryDependency[] @relation("DependencyTarget")
|
|
1647
1600
|
links StoryLink[]
|
|
1648
1601
|
attachments StoryAttachment[]
|
|
1649
|
-
linkedPrds
|
|
1602
|
+
linkedPrds StoryDesignLink[] @relation("StoryDesignLinks")
|
|
1650
1603
|
linkedDocs StoryDocLink[] @relation("StoryDocLinks")
|
|
1651
1604
|
linkedExternalDocs StoryExternalLink[] @relation("StoryExternalLinks")
|
|
1652
1605
|
iterationId String?
|
|
@@ -1660,6 +1613,9 @@ model Story {
|
|
|
1660
1613
|
@@index([assigneeId])
|
|
1661
1614
|
@@index([createdById])
|
|
1662
1615
|
@@map("stories")
|
|
1616
|
+
@@index([updatedById])
|
|
1617
|
+
@@index([parentId])
|
|
1618
|
+
@@index([iterationId])
|
|
1663
1619
|
}
|
|
1664
1620
|
|
|
1665
1621
|
// 全局标签
|
|
@@ -1668,11 +1624,13 @@ model Label {
|
|
|
1668
1624
|
name String @unique
|
|
1669
1625
|
color String @default("#6b7280")
|
|
1670
1626
|
createdById String
|
|
1671
|
-
createdBy User @relation("labelCreator", fields: [createdById], references: [id])
|
|
1627
|
+
createdBy User @relation("labelCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
1672
1628
|
stories StoryLabel[]
|
|
1629
|
+
bugLabels BugLabel[]
|
|
1673
1630
|
createdAt DateTime @default(now())
|
|
1674
1631
|
|
|
1675
1632
|
@@map("labels")
|
|
1633
|
+
@@index([createdById])
|
|
1676
1634
|
}
|
|
1677
1635
|
|
|
1678
1636
|
model StoryLabel {
|
|
@@ -1684,6 +1642,7 @@ model StoryLabel {
|
|
|
1684
1642
|
@@id([storyId, labelId])
|
|
1685
1643
|
@@index([labelId])
|
|
1686
1644
|
@@map("story_labels")
|
|
1645
|
+
@@index([storyId])
|
|
1687
1646
|
}
|
|
1688
1647
|
|
|
1689
1648
|
model StoryActivity {
|
|
@@ -1691,7 +1650,7 @@ model StoryActivity {
|
|
|
1691
1650
|
storyId String
|
|
1692
1651
|
story Story @relation(fields: [storyId], references: [id], onDelete: Cascade)
|
|
1693
1652
|
userId String
|
|
1694
|
-
user User @relation("storyActivityUser", fields: [userId], references: [id])
|
|
1653
|
+
user User @relation("storyActivityUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
1695
1654
|
action String
|
|
1696
1655
|
field String?
|
|
1697
1656
|
oldValue String? @db.Text
|
|
@@ -1702,6 +1661,7 @@ model StoryActivity {
|
|
|
1702
1661
|
|
|
1703
1662
|
@@index([storyId, createdAt])
|
|
1704
1663
|
@@map("story_activities")
|
|
1664
|
+
@@index([userId])
|
|
1705
1665
|
}
|
|
1706
1666
|
|
|
1707
1667
|
model SequenceCounter {
|
|
@@ -1717,7 +1677,7 @@ model StoryComment {
|
|
|
1717
1677
|
storyId String
|
|
1718
1678
|
story Story @relation(fields: [storyId], references: [id], onDelete: Cascade)
|
|
1719
1679
|
userId String
|
|
1720
|
-
user User @relation("storyCommentUser", fields: [userId], references: [id])
|
|
1680
|
+
user User @relation("storyCommentUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
1721
1681
|
parentId String?
|
|
1722
1682
|
parent StoryComment? @relation("CommentReply", fields: [parentId], references: [id], onDelete: Cascade)
|
|
1723
1683
|
replies StoryComment[] @relation("CommentReply")
|
|
@@ -1729,6 +1689,7 @@ model StoryComment {
|
|
|
1729
1689
|
@@index([storyId, createdAt])
|
|
1730
1690
|
@@index([parentId])
|
|
1731
1691
|
@@map("story_comments")
|
|
1692
|
+
@@index([userId])
|
|
1732
1693
|
}
|
|
1733
1694
|
|
|
1734
1695
|
model StoryReaction {
|
|
@@ -1736,7 +1697,7 @@ model StoryReaction {
|
|
|
1736
1697
|
storyId String
|
|
1737
1698
|
story Story @relation(fields: [storyId], references: [id], onDelete: Cascade)
|
|
1738
1699
|
userId String
|
|
1739
|
-
user User @relation("storyReactionUser", fields: [userId], references: [id])
|
|
1700
|
+
user User @relation("storyReactionUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
1740
1701
|
emoji String
|
|
1741
1702
|
createdAt DateTime @default(now())
|
|
1742
1703
|
|
|
@@ -1750,7 +1711,7 @@ model CommentReaction {
|
|
|
1750
1711
|
commentId String
|
|
1751
1712
|
comment StoryComment @relation(fields: [commentId], references: [id], onDelete: Cascade)
|
|
1752
1713
|
userId String
|
|
1753
|
-
user User @relation("commentReactionUser", fields: [userId], references: [id])
|
|
1714
|
+
user User @relation("commentReactionUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
1754
1715
|
emoji String
|
|
1755
1716
|
createdAt DateTime @default(now())
|
|
1756
1717
|
|
|
@@ -1831,6 +1792,7 @@ model WorkspaceQuickDoc {
|
|
|
1831
1792
|
@@index([workspaceId])
|
|
1832
1793
|
@@index([workspaceId, docId])
|
|
1833
1794
|
@@map("workspace_quick_docs")
|
|
1795
|
+
@@index([createdBy])
|
|
1834
1796
|
}
|
|
1835
1797
|
|
|
1836
1798
|
model StoryLink {
|
|
@@ -1867,19 +1829,19 @@ model StoryAttachment {
|
|
|
1867
1829
|
@@map("story_attachments")
|
|
1868
1830
|
}
|
|
1869
1831
|
|
|
1870
|
-
model
|
|
1832
|
+
model StoryDesignLink {
|
|
1871
1833
|
id String @id @default(cuid())
|
|
1872
1834
|
storyId String
|
|
1873
|
-
|
|
1835
|
+
designId String
|
|
1874
1836
|
createdAt DateTime @default(now())
|
|
1875
1837
|
|
|
1876
|
-
story Story @relation("
|
|
1877
|
-
|
|
1838
|
+
story Story @relation("StoryDesignLinks", fields: [storyId], references: [id], onDelete: Cascade)
|
|
1839
|
+
design Design @relation("DesignStoryLinks", fields: [designId], references: [id], onDelete: Cascade)
|
|
1878
1840
|
|
|
1879
|
-
@@unique([storyId,
|
|
1841
|
+
@@unique([storyId, designId])
|
|
1880
1842
|
@@index([storyId])
|
|
1881
|
-
@@index([
|
|
1882
|
-
@@map("
|
|
1843
|
+
@@index([designId])
|
|
1844
|
+
@@map("story_design_links")
|
|
1883
1845
|
}
|
|
1884
1846
|
|
|
1885
1847
|
model StoryDocLink {
|
|
@@ -1926,8 +1888,8 @@ model StoryFilterView {
|
|
|
1926
1888
|
description String?
|
|
1927
1889
|
icon String @default("list")
|
|
1928
1890
|
projectId String?
|
|
1929
|
-
filters Json
|
|
1930
|
-
displayOptions Json
|
|
1891
|
+
filters Json @default("{}")
|
|
1892
|
+
displayOptions Json @default("{}")
|
|
1931
1893
|
sortOrder Int @default(0)
|
|
1932
1894
|
createdAt DateTime @default(now())
|
|
1933
1895
|
updatedAt DateTime @updatedAt
|
|
@@ -2015,7 +1977,7 @@ model Plan {
|
|
|
2015
1977
|
maxGuestSeats Int?
|
|
2016
1978
|
maxWorkspaces Int?
|
|
2017
1979
|
aiQuotaMonthly Int?
|
|
2018
|
-
features Json
|
|
1980
|
+
features Json @default("{}")
|
|
2019
1981
|
isPublic Boolean @default(true)
|
|
2020
1982
|
sortOrder Int @default(0)
|
|
2021
1983
|
createdAt DateTime @default(now())
|
|
@@ -2050,9 +2012,9 @@ model Plan {
|
|
|
2050
2012
|
model Subscription {
|
|
2051
2013
|
id String @id @default(cuid())
|
|
2052
2014
|
userId String @unique
|
|
2053
|
-
user User @relation(fields: [userId], references: [id])
|
|
2015
|
+
user User @relation(fields: [userId], references: [id], onDelete: Restrict)
|
|
2054
2016
|
planId String
|
|
2055
|
-
plan Plan @relation(fields: [planId], references: [id])
|
|
2017
|
+
plan Plan @relation(fields: [planId], references: [id], onDelete: Restrict)
|
|
2056
2018
|
status SubscriptionStatus @default(ACTIVE)
|
|
2057
2019
|
|
|
2058
2020
|
/// 席位加购数量(账号级)。实际上限 = plan.maxSeats + addonSeats。
|
|
@@ -2077,6 +2039,7 @@ model Subscription {
|
|
|
2077
2039
|
invoices Invoice[]
|
|
2078
2040
|
|
|
2079
2041
|
@@map("subscriptions")
|
|
2042
|
+
@@index([planId])
|
|
2080
2043
|
}
|
|
2081
2044
|
|
|
2082
2045
|
enum SubscriptionStatus {
|
|
@@ -2092,7 +2055,7 @@ enum SubscriptionStatus {
|
|
|
2092
2055
|
model UsageRecord {
|
|
2093
2056
|
id String @id @default(cuid())
|
|
2094
2057
|
workspaceId String
|
|
2095
|
-
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
|
2058
|
+
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Restrict)
|
|
2096
2059
|
metric UsageMetric
|
|
2097
2060
|
period String
|
|
2098
2061
|
count Int @default(0)
|
|
@@ -2112,6 +2075,20 @@ enum UsageMetric {
|
|
|
2112
2075
|
SEAT
|
|
2113
2076
|
}
|
|
2114
2077
|
|
|
2078
|
+
/// 第三方依赖分类——值集与 kernel 的 DependencyCategory 联合类型对齐
|
|
2079
|
+
/// (packages/kernel/src/contract/modules/dependencies/index.ts,8 值)。
|
|
2080
|
+
/// 新增分类须两处同步:kernel 联合类型 + 本 enum + 迁移 ALTER TYPE ADD VALUE。
|
|
2081
|
+
enum DependencyCategory {
|
|
2082
|
+
framework
|
|
2083
|
+
ui
|
|
2084
|
+
editor
|
|
2085
|
+
ai
|
|
2086
|
+
state
|
|
2087
|
+
auth
|
|
2088
|
+
tool
|
|
2089
|
+
other
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2115
2092
|
/// AI 用量明细(按次扣减 + 成本审计)
|
|
2116
2093
|
model AiUsageLog {
|
|
2117
2094
|
id String @id @default(cuid())
|
|
@@ -2120,7 +2097,7 @@ model AiUsageLog {
|
|
|
2120
2097
|
workspaceId String?
|
|
2121
2098
|
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: Restrict)
|
|
2122
2099
|
userId String
|
|
2123
|
-
user User @relation(fields: [userId], references: [id])
|
|
2100
|
+
user User @relation(fields: [userId], references: [id], onDelete: Restrict)
|
|
2124
2101
|
source String @default("byok")
|
|
2125
2102
|
activity String? // 区分 chat/sandbox/image...(P3 计费维度;null = 既有 byok 语义)
|
|
2126
2103
|
provider String
|
|
@@ -2147,7 +2124,7 @@ model AiUsageLog {
|
|
|
2147
2124
|
model Invoice {
|
|
2148
2125
|
id String @id @default(cuid())
|
|
2149
2126
|
subscriptionId String
|
|
2150
|
-
subscription Subscription @relation(fields: [subscriptionId], references: [id])
|
|
2127
|
+
subscription Subscription @relation(fields: [subscriptionId], references: [id], onDelete: Restrict)
|
|
2151
2128
|
providerInvoiceId String @unique
|
|
2152
2129
|
providerEventId String?
|
|
2153
2130
|
amountDue Int
|
|
@@ -2189,27 +2166,29 @@ model LicenseKey {
|
|
|
2189
2166
|
id String @id @default(cuid())
|
|
2190
2167
|
key String @unique
|
|
2191
2168
|
signature String
|
|
2192
|
-
payload Json
|
|
2169
|
+
payload Json @default("{}")
|
|
2193
2170
|
customerId String
|
|
2194
2171
|
customerName String
|
|
2195
2172
|
customerEmail String
|
|
2196
2173
|
plan String @default("enterprise")
|
|
2197
2174
|
seats Int
|
|
2198
|
-
features Json
|
|
2175
|
+
features Json @default("{}")
|
|
2199
2176
|
issuedAt DateTime @default(now())
|
|
2200
2177
|
expiresAt DateTime?
|
|
2201
2178
|
revokedAt DateTime?
|
|
2202
2179
|
issuedById String?
|
|
2203
|
-
issuedBy User? @relation("LicenseIssuer", fields: [issuedById], references: [id])
|
|
2180
|
+
issuedBy User? @relation("LicenseIssuer", fields: [issuedById], references: [id], onDelete: SetNull)
|
|
2204
2181
|
activations LicenseActivation[]
|
|
2205
2182
|
|
|
2206
2183
|
@@map("license_keys")
|
|
2184
|
+
@@index([issuedById])
|
|
2185
|
+
@@index([customerId])
|
|
2207
2186
|
}
|
|
2208
2187
|
|
|
2209
2188
|
model LicenseActivation {
|
|
2210
2189
|
id String @id @default(cuid())
|
|
2211
2190
|
licenseId String
|
|
2212
|
-
license LicenseKey @relation(fields: [licenseId], references: [id])
|
|
2191
|
+
license LicenseKey @relation(fields: [licenseId], references: [id], onDelete: Cascade)
|
|
2213
2192
|
instanceId String @unique
|
|
2214
2193
|
fingerprint String
|
|
2215
2194
|
activatedAt DateTime @default(now())
|
|
@@ -2217,18 +2196,19 @@ model LicenseActivation {
|
|
|
2217
2196
|
revokedAt DateTime?
|
|
2218
2197
|
|
|
2219
2198
|
@@map("license_activations")
|
|
2199
|
+
@@index([licenseId])
|
|
2220
2200
|
}
|
|
2221
2201
|
|
|
2222
2202
|
// 审计日志
|
|
2223
2203
|
model AuditLog {
|
|
2224
2204
|
id String @id @default(cuid())
|
|
2225
2205
|
workspaceId String?
|
|
2226
|
-
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
|
2206
|
+
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: SetNull)
|
|
2227
2207
|
userId String?
|
|
2228
2208
|
action String
|
|
2229
2209
|
resourceType String
|
|
2230
2210
|
resourceId String?
|
|
2231
|
-
metadata Json
|
|
2211
|
+
metadata Json @default("{}")
|
|
2232
2212
|
ip String?
|
|
2233
2213
|
userAgent String?
|
|
2234
2214
|
createdAt DateTime @default(now())
|
|
@@ -2243,10 +2223,10 @@ model AuditLog {
|
|
|
2243
2223
|
model SsoProvider {
|
|
2244
2224
|
id String @id @default(cuid())
|
|
2245
2225
|
workspaceId String
|
|
2246
|
-
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
|
2226
|
+
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Restrict)
|
|
2247
2227
|
type String
|
|
2248
2228
|
name String
|
|
2249
|
-
config Json
|
|
2229
|
+
config Json @default("{}")
|
|
2250
2230
|
domain String?
|
|
2251
2231
|
enabled Boolean @default(true)
|
|
2252
2232
|
createdAt DateTime @default(now())
|
|
@@ -2260,24 +2240,25 @@ model SsoProvider {
|
|
|
2260
2240
|
model SsoMapping {
|
|
2261
2241
|
id String @id @default(cuid())
|
|
2262
2242
|
providerId String
|
|
2263
|
-
provider SsoProvider @relation(fields: [providerId], references: [id])
|
|
2243
|
+
provider SsoProvider @relation(fields: [providerId], references: [id], onDelete: Cascade)
|
|
2264
2244
|
externalId String
|
|
2265
2245
|
userId String
|
|
2266
|
-
user User @relation(fields: [userId], references: [id])
|
|
2246
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
2267
2247
|
email String?
|
|
2268
2248
|
createdAt DateTime @default(now())
|
|
2269
2249
|
|
|
2270
2250
|
@@unique([providerId, externalId])
|
|
2271
2251
|
@@map("sso_mappings")
|
|
2252
|
+
@@index([userId])
|
|
2272
2253
|
}
|
|
2273
2254
|
|
|
2274
2255
|
// 自定义角色
|
|
2275
2256
|
model CustomRole {
|
|
2276
2257
|
id String @id @default(cuid())
|
|
2277
2258
|
workspaceId String
|
|
2278
|
-
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
|
2259
|
+
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Restrict)
|
|
2279
2260
|
name String
|
|
2280
|
-
permissions Json
|
|
2261
|
+
permissions Json @default("{}")
|
|
2281
2262
|
isSystem Boolean @default(false)
|
|
2282
2263
|
createdAt DateTime @default(now())
|
|
2283
2264
|
updatedAt DateTime @updatedAt
|
|
@@ -2290,9 +2271,9 @@ model CustomRole {
|
|
|
2290
2271
|
model RoleAssignment {
|
|
2291
2272
|
id String @id @default(cuid())
|
|
2292
2273
|
roleId String
|
|
2293
|
-
role CustomRole @relation(fields: [roleId], references: [id])
|
|
2274
|
+
role CustomRole @relation(fields: [roleId], references: [id], onDelete: Cascade)
|
|
2294
2275
|
userId String
|
|
2295
|
-
user User @relation(fields: [userId], references: [id])
|
|
2276
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
2296
2277
|
createdAt DateTime @default(now())
|
|
2297
2278
|
|
|
2298
2279
|
@@unique([roleId, userId])
|
|
@@ -2400,7 +2381,7 @@ model Notification {
|
|
|
2400
2381
|
// 通知偏好(免打扰时段、分类开关)
|
|
2401
2382
|
model NotificationPreference {
|
|
2402
2383
|
userId String @id
|
|
2403
|
-
categories Json
|
|
2384
|
+
categories Json @default("{}")
|
|
2404
2385
|
emailCategories Json @default("{}")
|
|
2405
2386
|
dndEnabled Boolean @default(false)
|
|
2406
2387
|
dndStart String @default("22:00")
|
|
@@ -2422,14 +2403,16 @@ model Iteration {
|
|
|
2422
2403
|
archived Boolean @default(false)
|
|
2423
2404
|
archivedAt DateTime?
|
|
2424
2405
|
createdById String
|
|
2425
|
-
createdBy User @relation("iterationCreator", fields: [createdById], references: [id])
|
|
2406
|
+
createdBy User @relation("iterationCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
2426
2407
|
createdAt DateTime @default(now())
|
|
2427
2408
|
updatedAt DateTime @updatedAt
|
|
2428
2409
|
stories Story[]
|
|
2410
|
+
testPlans TestPlan[]
|
|
2429
2411
|
|
|
2430
2412
|
@@index([projectId, startDate])
|
|
2431
2413
|
@@index([archived])
|
|
2432
2414
|
@@map("iterations")
|
|
2415
|
+
@@index([createdById])
|
|
2433
2416
|
}
|
|
2434
2417
|
|
|
2435
2418
|
// 迭代自动排期配置(一项目一行)
|
|
@@ -2490,7 +2473,7 @@ model SandboxInstance {
|
|
|
2490
2473
|
model AiStreamChunk {
|
|
2491
2474
|
id BigInt @id @default(autoincrement())
|
|
2492
2475
|
runId String
|
|
2493
|
-
chunk Json
|
|
2476
|
+
chunk Json @default("{}")
|
|
2494
2477
|
createdAt DateTime @default(now())
|
|
2495
2478
|
|
|
2496
2479
|
@@index([runId, id])
|
|
@@ -2499,7 +2482,7 @@ model AiStreamChunk {
|
|
|
2499
2482
|
|
|
2500
2483
|
model DesktopSetting {
|
|
2501
2484
|
key String @id // "aiSourceMode" | "localAgentConfig"
|
|
2502
|
-
value Json
|
|
2485
|
+
value Json @default("{}")
|
|
2503
2486
|
|
|
2504
2487
|
@@map("desktop_settings")
|
|
2505
2488
|
}
|
|
@@ -2554,3 +2537,575 @@ model Blob {
|
|
|
2554
2537
|
@@index([userId])
|
|
2555
2538
|
@@map("blobs")
|
|
2556
2539
|
}
|
|
2540
|
+
|
|
2541
|
+
// ==================== BUG 模块(仅 PG schema,桌面端无 BUG 模块,见规格 ADR-5) ====================
|
|
2542
|
+
|
|
2543
|
+
// BUG 工单主表
|
|
2544
|
+
model Bug {
|
|
2545
|
+
id String @id @default(cuid())
|
|
2546
|
+
sequenceId Int
|
|
2547
|
+
identifier String // "{displayId}-B{seq}"(如 "ABC-B12"),SequenceCounter(scope="bug:{projectId}") 独立发号,前缀加 -B 与需求 identifier 区分
|
|
2548
|
+
projectId String
|
|
2549
|
+
title String
|
|
2550
|
+
description String? @db.Text // TipTap {html, markdown} JSON,与 Story.description 同构
|
|
2551
|
+
reproduceSteps Json? // { steps: [{ order: Int, action: String, expected?: String }], expectedResult?: String, actualResult?: String }
|
|
2552
|
+
state String @default("open") // open|in_progress|fixed|closed|wontfix
|
|
2553
|
+
severity String @default("medium") // critical|high|medium|low
|
|
2554
|
+
source String @default("manual") // manual|sdk_auto|collect|chrome_ext|test_run(test_run:测试执行失败 AI 起草,规格 Q2)
|
|
2555
|
+
pendingConfirm Boolean @default(false) // Q2:AI 起草待确认标记(仅 source=test_run 使用)
|
|
2556
|
+
fingerprint String? // sha256 hex,服务端计算;手动创建为 null
|
|
2557
|
+
env String? // SDK 上报环境:prod|test|dev|自定义
|
|
2558
|
+
url String? @db.Text // 发生页面 URL
|
|
2559
|
+
userAgent String? @db.Text
|
|
2560
|
+
stackSummary String? @db.Text // 归一化前原始堆栈(截断存储,≤64KB;title 截 80 字符、url/ua 截 2KB)
|
|
2561
|
+
totalCount Int @default(1) // 累计上报/命中次数
|
|
2562
|
+
firstOccurAt DateTime @default(now())
|
|
2563
|
+
lastOccurAt DateTime @default(now())
|
|
2564
|
+
assigneeId String?
|
|
2565
|
+
createdById String
|
|
2566
|
+
updatedById String?
|
|
2567
|
+
storyId String? // 关联需求(单值 FK,可空)
|
|
2568
|
+
repoHints String? @db.Text // AI 复现用仓库线索(如 "github.com/org/repo,登录页 src/views/Login.tsx")
|
|
2569
|
+
archived Boolean @default(false)
|
|
2570
|
+
archivedAt DateTime?
|
|
2571
|
+
boardOrder Int @default(0) // 看板列内手动排序权重(二三期看板拖拽排序用)
|
|
2572
|
+
createdAt DateTime @default(now())
|
|
2573
|
+
updatedAt DateTime @updatedAt
|
|
2574
|
+
|
|
2575
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Restrict)
|
|
2576
|
+
story Story? @relation(fields: [storyId], references: [id], onDelete: SetNull)
|
|
2577
|
+
assignee User? @relation("bugAssignee", fields: [assigneeId], references: [id], onDelete: SetNull)
|
|
2578
|
+
createdBy User @relation("bugCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
2579
|
+
updatedBy User? @relation("bugEditor", fields: [updatedById], references: [id], onDelete: SetNull)
|
|
2580
|
+
|
|
2581
|
+
events BugEvent[]
|
|
2582
|
+
activities BugActivity[]
|
|
2583
|
+
comments BugComment[]
|
|
2584
|
+
fixRuns BugFixRun[]
|
|
2585
|
+
reproRuns BugReproRun[]
|
|
2586
|
+
labels BugLabel[]
|
|
2587
|
+
runCases TestRunCase[]
|
|
2588
|
+
|
|
2589
|
+
@@unique([projectId, identifier])
|
|
2590
|
+
@@unique([projectId, fingerprint]) // 可空字段 unique:多个 null 不冲突,手动 BUG 互不影响
|
|
2591
|
+
@@index([projectId, sequenceId])
|
|
2592
|
+
@@index([state])
|
|
2593
|
+
@@index([archived, state, createdAt])
|
|
2594
|
+
@@index([assigneeId])
|
|
2595
|
+
@@index([createdById])
|
|
2596
|
+
@@index([storyId])
|
|
2597
|
+
@@index([projectId, lastOccurAt])
|
|
2598
|
+
@@index([projectId, boardOrder])
|
|
2599
|
+
@@map("bugs")
|
|
2600
|
+
@@index([updatedById])
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
// 事件明细(采样存储:同指纹时间窗口内最多存 1 条快照)
|
|
2604
|
+
model BugEvent {
|
|
2605
|
+
id String @id @default(cuid())
|
|
2606
|
+
bugId String
|
|
2607
|
+
bug Bug @relation(fields: [bugId], references: [id], onDelete: Cascade)
|
|
2608
|
+
rawPayload Json // 精简后的原始上报报文(堆栈/面包屑/浏览器/自定义 extra);受请求级 256KB 上限约束,落库前再按事件截断至 64KB
|
|
2609
|
+
occurTime DateTime @default(now())
|
|
2610
|
+
userAgent String? @db.Text
|
|
2611
|
+
|
|
2612
|
+
@@index([bugId, occurTime])
|
|
2613
|
+
@@map("bug_events")
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2616
|
+
// 活动流水(照 StoryActivity 模式;两处有意偏离:userId 可空 + actorType/agentName,SDK 与 AI agent 写入的活动无登录用户)
|
|
2617
|
+
model BugActivity {
|
|
2618
|
+
id String @id @default(cuid())
|
|
2619
|
+
bugId String
|
|
2620
|
+
bug Bug @relation(fields: [bugId], references: [id], onDelete: Cascade)
|
|
2621
|
+
userId String? // 手动操作时必填;sdk/agent 产生时为 null
|
|
2622
|
+
user User? @relation("bugActivityUser", fields: [userId], references: [id], onDelete: SetNull)
|
|
2623
|
+
actorType String @default("user") // user|sdk|agent|system
|
|
2624
|
+
agentName String? // actorType=agent 时标识(如 "opencode")
|
|
2625
|
+
action String // created|state_changed|severity_changed|assigned|...|sdk_reported|reopened_by_sdk|fix_claimed|fix_progress|fix_completed|converted_to_story|linked_story|ai_repro_completed
|
|
2626
|
+
field String?
|
|
2627
|
+
oldValue String? @db.Text
|
|
2628
|
+
newValue String? @db.Text
|
|
2629
|
+
isAI Boolean @default(false)
|
|
2630
|
+
metadata Json?
|
|
2631
|
+
createdAt DateTime @default(now())
|
|
2632
|
+
|
|
2633
|
+
@@index([bugId, createdAt])
|
|
2634
|
+
@@map("bug_activities")
|
|
2635
|
+
@@index([userId])
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
// 评论(照 StoryComment:parentId 自关联回复树)
|
|
2639
|
+
model BugComment {
|
|
2640
|
+
id String @id @default(cuid())
|
|
2641
|
+
bugId String
|
|
2642
|
+
bug Bug @relation(fields: [bugId], references: [id], onDelete: Cascade)
|
|
2643
|
+
userId String
|
|
2644
|
+
user User @relation("bugCommentUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
2645
|
+
parentId String?
|
|
2646
|
+
parent BugComment? @relation("BugCommentReply", fields: [parentId], references: [id], onDelete: Cascade)
|
|
2647
|
+
replies BugComment[] @relation("BugCommentReply")
|
|
2648
|
+
content String @db.Text
|
|
2649
|
+
reactions BugCommentReaction[]
|
|
2650
|
+
createdAt DateTime @default(now())
|
|
2651
|
+
updatedAt DateTime @updatedAt
|
|
2652
|
+
|
|
2653
|
+
@@index([bugId, createdAt])
|
|
2654
|
+
@@index([parentId])
|
|
2655
|
+
@@map("bug_comments")
|
|
2656
|
+
@@index([userId])
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
// Bug 评论表情(照 CommentReaction 同构;pg-only:Bug 评论域不上桌面端)
|
|
2660
|
+
model BugCommentReaction {
|
|
2661
|
+
id String @id @default(cuid())
|
|
2662
|
+
commentId String
|
|
2663
|
+
comment BugComment @relation(fields: [commentId], references: [id], onDelete: Cascade)
|
|
2664
|
+
userId String
|
|
2665
|
+
user User @relation("bugCommentReactionUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
2666
|
+
emoji String
|
|
2667
|
+
createdAt DateTime @default(now())
|
|
2668
|
+
|
|
2669
|
+
@@unique([commentId, userId, emoji])
|
|
2670
|
+
@@index([commentId])
|
|
2671
|
+
@@map("bug_comment_reactions")
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
// 统一项目接入凭证(一张表 + scope 区分类别,替代三张独立 token 表)
|
|
2675
|
+
model ProjectAccessToken {
|
|
2676
|
+
id String @id @default(cuid())
|
|
2677
|
+
projectId String
|
|
2678
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2679
|
+
name String // 展示名:"生产环境" / "公开收集页" / "opencode"
|
|
2680
|
+
scope String // bug.report(SDK/扩展上报) | bug.collect(收集页) | bug.mcp(MCP) | test.exec(AI 执行)
|
|
2681
|
+
tokenHash String @unique // sha256(明文),明文不落库
|
|
2682
|
+
tokenPrefix String // 明文前 8 字符("abk_9x8z"),列表识别用
|
|
2683
|
+
config Json? // scope=bug.collect: { title?, description?, severityVisible?, screenshotEnabled? }
|
|
2684
|
+
lastUsedAt DateTime?
|
|
2685
|
+
revokedAt DateTime? // 非空即吊销
|
|
2686
|
+
createdById String
|
|
2687
|
+
// 产品决策(审查修复):Restrict——token 是项目级活凭证(bug.report SDK / test.exec CI),
|
|
2688
|
+
// 非创建者个人内容;删创建者静默销毁凭证会让集成端 401。createdById required 无法 SetNull。
|
|
2689
|
+
createdBy User @relation("tokenCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
2690
|
+
createdAt DateTime @default(now())
|
|
2691
|
+
|
|
2692
|
+
@@index([projectId, scope])
|
|
2693
|
+
@@map("project_access_tokens")
|
|
2694
|
+
@@index([createdById])
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
// AI 修复状态机:pending →(claim_fix) claimed →(report_progress 首次) in_progress →(report_result) completed|failed;用户可取消 → cancelled
|
|
2698
|
+
model BugFixRun {
|
|
2699
|
+
id String @id @default(cuid())
|
|
2700
|
+
bugId String
|
|
2701
|
+
bug Bug @relation(fields: [bugId], references: [id], onDelete: Cascade)
|
|
2702
|
+
status String @default("pending") // pending|claimed|in_progress|completed|failed|cancelled
|
|
2703
|
+
triggerType String // manual|auto
|
|
2704
|
+
agentName String? // claim_fix 时由 MCP 客户端传入(tool 入参)
|
|
2705
|
+
claimedAt DateTime?
|
|
2706
|
+
completedAt DateTime?
|
|
2707
|
+
summary Json? // { result: "fixed"|"failed"|"cannot_reproduce", summaryText, commitUrl?, prUrl?, changedFiles: String[] }
|
|
2708
|
+
createdAt DateTime @default(now())
|
|
2709
|
+
|
|
2710
|
+
@@index([bugId, createdAt])
|
|
2711
|
+
@@index([status, createdAt])
|
|
2712
|
+
@@map("bug_fix_runs")
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
// AI 复现(mode=static;dynamic 为 P2 预留)
|
|
2716
|
+
model BugReproRun {
|
|
2717
|
+
id String @id @default(cuid())
|
|
2718
|
+
bugId String
|
|
2719
|
+
bug Bug @relation(fields: [bugId], references: [id], onDelete: Cascade)
|
|
2720
|
+
mode String @default("static") // static|dynamic(MVP 仅 static)
|
|
2721
|
+
status String @default("running") // running|completed|failed
|
|
2722
|
+
report Json? // 结构化报告(规格 §12)
|
|
2723
|
+
error String? @db.Text
|
|
2724
|
+
createdById String
|
|
2725
|
+
createdBy User @relation("bugReproCreator", fields: [createdById], references: [id], onDelete: Cascade)
|
|
2726
|
+
createdAt DateTime @default(now())
|
|
2727
|
+
|
|
2728
|
+
@@index([bugId, createdAt])
|
|
2729
|
+
@@map("bug_repro_runs")
|
|
2730
|
+
@@index([createdById])
|
|
2731
|
+
}
|
|
2732
|
+
|
|
2733
|
+
// 出站通知(HMAC-SHA256 签名;MVP 同步 fire-and-forget + 5s 超时,不建投递表)
|
|
2734
|
+
model ProjectWebhook {
|
|
2735
|
+
id String @id @default(cuid())
|
|
2736
|
+
projectId String
|
|
2737
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2738
|
+
url String @db.Text
|
|
2739
|
+
secret String @db.Text // HMAC-SHA256 签名密钥
|
|
2740
|
+
events Json @default("[]") // ["bug.created","fix.requested","fix.completed"]
|
|
2741
|
+
enabled Boolean @default(true)
|
|
2742
|
+
createdAt DateTime @default(now())
|
|
2743
|
+
|
|
2744
|
+
@@index([projectId])
|
|
2745
|
+
@@map("project_webhooks")
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
// 项目级 BUG 配置(PG only 独立表守 ADR-5 边界;projectId 为主键一项目一行,首次访问惰性 upsert 建行)
|
|
2749
|
+
model BugProjectSettings {
|
|
2750
|
+
projectId String @id
|
|
2751
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2752
|
+
autoReportEnabled Boolean @default(true) // SDK 上报总开关(关:上报接口对该项目返回 ok 但丢弃)
|
|
2753
|
+
sampleRate Float @default(1) // 服务端二次采样(0-1,与 SDK 端采样独立叠加)
|
|
2754
|
+
reopenOnDuplicate Boolean @default(true) // fixed/closed 收到重复上报自动转 open
|
|
2755
|
+
autoFixEnabled Boolean @default(false) // 新指纹 BUG 自动入队 AI 修复
|
|
2756
|
+
autoSubmitTestBugs Boolean @default(false) // true=跳过人工确认闸门(测试失败 AI 起草 bug 直接转正,规格 Q2)
|
|
2757
|
+
updatedAt DateTime @updatedAt
|
|
2758
|
+
|
|
2759
|
+
@@map("bug_project_settings")
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2762
|
+
// BUG ↔ 标签 join 表(照 StoryLabel,标签池与 Story 共用)
|
|
2763
|
+
model BugLabel {
|
|
2764
|
+
bugId String
|
|
2765
|
+
labelId String
|
|
2766
|
+
bug Bug @relation(fields: [bugId], references: [id], onDelete: Cascade)
|
|
2767
|
+
label Label @relation(fields: [labelId], references: [id], onDelete: Cascade)
|
|
2768
|
+
|
|
2769
|
+
@@id([bugId, labelId])
|
|
2770
|
+
@@index([bugId])
|
|
2771
|
+
@@index([labelId])
|
|
2772
|
+
@@map("bug_labels")
|
|
2773
|
+
}
|
|
2774
|
+
|
|
2775
|
+
// BUG 列表过滤器视图(per-user 保存,照 StoryFilterView 字段结构;无 bugId 关联)
|
|
2776
|
+
model BugFilterView {
|
|
2777
|
+
id String @id @default(cuid())
|
|
2778
|
+
userId String
|
|
2779
|
+
name String
|
|
2780
|
+
projectId String?
|
|
2781
|
+
filters Json @default("{}")
|
|
2782
|
+
displayOptions Json @default("{}")
|
|
2783
|
+
createdAt DateTime @default(now())
|
|
2784
|
+
updatedAt DateTime @updatedAt
|
|
2785
|
+
|
|
2786
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
2787
|
+
|
|
2788
|
+
@@index([userId])
|
|
2789
|
+
@@map("bug_filter_views")
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
// ==================== 测试用例模块(仅 PG schema,D7:桌面端不同步,规格 2026-10-04-testcase-module §3) ====================
|
|
2793
|
+
|
|
2794
|
+
// 用例主表(identifier 由 SequenceCounter(scope="testcase:{projectId}") 发号)
|
|
2795
|
+
model TestCase {
|
|
2796
|
+
id String @id @default(cuid())
|
|
2797
|
+
sequenceId Int
|
|
2798
|
+
identifier String // "{displayId}-TC{seq}",SequenceCounter(scope="testcase:{projectId}")
|
|
2799
|
+
projectId String
|
|
2800
|
+
folderId String?
|
|
2801
|
+
storyId String?
|
|
2802
|
+
title String
|
|
2803
|
+
precondition String? @db.Text
|
|
2804
|
+
steps Json @default("{\"steps\":[]}") // { steps: [{ order, action, expected? }] }——与 Bug.reproduceSteps 步骤结构同构
|
|
2805
|
+
type String @default("functional") // functional|boundary|exception|performance|security|compatibility
|
|
2806
|
+
priority String @default("p1") // p0|p1|p2|p3
|
|
2807
|
+
state String @default("draft") // draft|in_review|approved|deprecated
|
|
2808
|
+
version Int @default(1) // 每次内容编辑 +1
|
|
2809
|
+
automation String @default("none") // none|unit|e2e|both
|
|
2810
|
+
aiGenerated Boolean @default(false)
|
|
2811
|
+
generationId String?
|
|
2812
|
+
assigneeId String?
|
|
2813
|
+
createdById String
|
|
2814
|
+
archived Boolean @default(false)
|
|
2815
|
+
archivedAt DateTime?
|
|
2816
|
+
boardOrder Int @default(0) // 看板列内手动排序权重(二三期看板拖拽排序用)
|
|
2817
|
+
createdAt DateTime @default(now())
|
|
2818
|
+
updatedAt DateTime @updatedAt
|
|
2819
|
+
|
|
2820
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Restrict)
|
|
2821
|
+
folder TestCaseFolder? @relation(fields: [folderId], references: [id], onDelete: SetNull)
|
|
2822
|
+
story Story? @relation(fields: [storyId], references: [id], onDelete: SetNull)
|
|
2823
|
+
assignee User? @relation("testCaseAssignee", fields: [assigneeId], references: [id], onDelete: SetNull)
|
|
2824
|
+
createdBy User @relation("testCaseCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
2825
|
+
artifacts TestAutomationArtifact[]
|
|
2826
|
+
runCases TestRunCase[]
|
|
2827
|
+
planCases TestPlanCase[]
|
|
2828
|
+
|
|
2829
|
+
@@unique([projectId, identifier])
|
|
2830
|
+
@@index([projectId, folderId])
|
|
2831
|
+
@@index([projectId, state])
|
|
2832
|
+
@@index([projectId, boardOrder])
|
|
2833
|
+
@@index([storyId])
|
|
2834
|
+
@@map("test_cases")
|
|
2835
|
+
@@index([assigneeId])
|
|
2836
|
+
@@index([createdById])
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
// 模块树
|
|
2840
|
+
model TestCaseFolder {
|
|
2841
|
+
id String @id @default(cuid())
|
|
2842
|
+
projectId String
|
|
2843
|
+
parentId String?
|
|
2844
|
+
name String
|
|
2845
|
+
position Int @default(0)
|
|
2846
|
+
|
|
2847
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2848
|
+
parent TestCaseFolder? @relation("FolderTree", fields: [parentId], references: [id], onDelete: Cascade)
|
|
2849
|
+
children TestCaseFolder[] @relation("FolderTree")
|
|
2850
|
+
cases TestCase[]
|
|
2851
|
+
|
|
2852
|
+
@@index([projectId, parentId])
|
|
2853
|
+
@@map("test_case_folders")
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
// 保存的筛选视图(结构对齐 StoryFilterView;projectId 仅普通列,无项目 FK)
|
|
2857
|
+
model TestCaseFilterView {
|
|
2858
|
+
id String @id @default(cuid())
|
|
2859
|
+
userId String
|
|
2860
|
+
name String
|
|
2861
|
+
description String?
|
|
2862
|
+
icon String @default("list")
|
|
2863
|
+
projectId String?
|
|
2864
|
+
filters Json @default("{}") // { folderId?, type?, priority?, state?, automation?, assigneeId?, label?, storyId?, searchText? }
|
|
2865
|
+
displayOptions Json @default("{}") // { groupBy: "folder"|"state"|"priority"|"none", view: "list"|"table", density? }
|
|
2866
|
+
sortOrder Int @default(0)
|
|
2867
|
+
createdAt DateTime @default(now())
|
|
2868
|
+
updatedAt DateTime @updatedAt
|
|
2869
|
+
|
|
2870
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
2871
|
+
|
|
2872
|
+
@@index([userId, projectId])
|
|
2873
|
+
@@map("test_case_filter_views")
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
// AI 生成批次(从 Story 结构化生成草稿,人工评审采纳)
|
|
2877
|
+
model TestGenerationRun {
|
|
2878
|
+
id String @id @default(cuid())
|
|
2879
|
+
projectId String
|
|
2880
|
+
storyId String
|
|
2881
|
+
status String @default("running") // running|completed|failed
|
|
2882
|
+
error String? @db.Text
|
|
2883
|
+
input Json? // { storySnapshot: {name, descriptionText}, acceptanceCriteria: string[], kbContext: {docId, excerpt}[] }
|
|
2884
|
+
output Json? // AI 原始结构化产物(评审对照)
|
|
2885
|
+
draftCount Int @default(0)
|
|
2886
|
+
adoptedCount Int @default(0)
|
|
2887
|
+
createdById String
|
|
2888
|
+
createdAt DateTime @default(now())
|
|
2889
|
+
completedAt DateTime?
|
|
2890
|
+
|
|
2891
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2892
|
+
story Story @relation(fields: [storyId], references: [id], onDelete: Cascade)
|
|
2893
|
+
createdBy User @relation("testGenCreator", fields: [createdById], references: [id], onDelete: Cascade)
|
|
2894
|
+
|
|
2895
|
+
@@index([projectId, createdAt])
|
|
2896
|
+
@@index([storyId])
|
|
2897
|
+
@@map("test_generation_runs")
|
|
2898
|
+
@@index([createdById])
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
// 测试计划
|
|
2902
|
+
model TestPlan {
|
|
2903
|
+
id String @id @default(cuid())
|
|
2904
|
+
projectId String
|
|
2905
|
+
iterationId String?
|
|
2906
|
+
name String
|
|
2907
|
+
description String? @db.Text
|
|
2908
|
+
state String @default("active") // active|closed
|
|
2909
|
+
createdById String
|
|
2910
|
+
createdAt DateTime @default(now())
|
|
2911
|
+
updatedAt DateTime @updatedAt
|
|
2912
|
+
|
|
2913
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2914
|
+
iteration Iteration? @relation(fields: [iterationId], references: [id], onDelete: SetNull)
|
|
2915
|
+
runs TestRun[]
|
|
2916
|
+
planCases TestPlanCase[]
|
|
2917
|
+
@@index([projectId, state])
|
|
2918
|
+
@@map("test_plans")
|
|
2919
|
+
@@index([iterationId])
|
|
2920
|
+
}
|
|
2921
|
+
|
|
2922
|
+
// 计划-用例圈选关联(TestPlanCase):@@unique([planId, caseId]) 保证重复加入不产生重复行
|
|
2923
|
+
//(addCasesToPlan 幂等的 DB 层防线);用例/计划删除时级联清理。
|
|
2924
|
+
model TestPlanCase {
|
|
2925
|
+
id String @id @default(cuid())
|
|
2926
|
+
planId String
|
|
2927
|
+
caseId String
|
|
2928
|
+
createdAt DateTime @default(now())
|
|
2929
|
+
|
|
2930
|
+
plan TestPlan @relation(fields: [planId], references: [id], onDelete: Cascade)
|
|
2931
|
+
case TestCase @relation(fields: [caseId], references: [id], onDelete: Cascade)
|
|
2932
|
+
|
|
2933
|
+
@@unique([planId, caseId])
|
|
2934
|
+
@@index([caseId])
|
|
2935
|
+
@@map("test_plan_cases")
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
// 执行批次
|
|
2939
|
+
model TestRun {
|
|
2940
|
+
id String @id @default(cuid())
|
|
2941
|
+
projectId String
|
|
2942
|
+
planId String?
|
|
2943
|
+
name String
|
|
2944
|
+
trigger String @default("manual") // manual|ai|schedule|webhook
|
|
2945
|
+
executorType String @default("human") // human|ai_agent|automation_code|mixed
|
|
2946
|
+
targetEnv String? // 环境标识/URL
|
|
2947
|
+
status String @default("running") // running|completed|aborted
|
|
2948
|
+
summary Json? // { total, passed, failed, blocked, skipped, retest, passRate, durationMs }
|
|
2949
|
+
startedAt DateTime?
|
|
2950
|
+
completedAt DateTime?
|
|
2951
|
+
createdById String
|
|
2952
|
+
createdAt DateTime @default(now())
|
|
2953
|
+
|
|
2954
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2955
|
+
plan TestPlan? @relation(fields: [planId], references: [id], onDelete: SetNull)
|
|
2956
|
+
cases TestRunCase[]
|
|
2957
|
+
@@index([projectId, createdAt])
|
|
2958
|
+
@@index([planId])
|
|
2959
|
+
@@map("test_runs")
|
|
2960
|
+
}
|
|
2961
|
+
|
|
2962
|
+
// 批次内用例执行记录(caseSnapshot 快照锁版本)
|
|
2963
|
+
model TestRunCase {
|
|
2964
|
+
id String @id @default(cuid())
|
|
2965
|
+
runId String
|
|
2966
|
+
caseId String
|
|
2967
|
+
caseVersion Int
|
|
2968
|
+
caseSnapshot Json @default("{}") // { title, precondition, steps, priority, type }——执行时快照
|
|
2969
|
+
status String @default("untested") // untested|passed|failed|blocked|skipped|retest
|
|
2970
|
+
stepResults Json? // [{ order, status: pass|fail|blocked|skip, actual?, evidenceBlobIds?: string[] }]
|
|
2971
|
+
actualResult String? @db.Text
|
|
2972
|
+
bugId String?
|
|
2973
|
+
execRunId String?
|
|
2974
|
+
flaky Boolean @default(false)
|
|
2975
|
+
fingerprint String?
|
|
2976
|
+
startedAt DateTime?
|
|
2977
|
+
finishedAt DateTime?
|
|
2978
|
+
durationMs Int?
|
|
2979
|
+
executedById String?
|
|
2980
|
+
|
|
2981
|
+
run TestRun @relation(fields: [runId], references: [id], onDelete: Cascade)
|
|
2982
|
+
case TestCase @relation(fields: [caseId], references: [id], onDelete: Cascade)
|
|
2983
|
+
bug Bug? @relation(fields: [bugId], references: [id], onDelete: SetNull)
|
|
2984
|
+
execRun TestExecRun? @relation("testExecCurrent", fields: [execRunId], references: [id], onDelete: SetNull)
|
|
2985
|
+
execRuns TestExecRun[] @relation("testExecHistory")
|
|
2986
|
+
executedBy User? @relation("testRunCaseExecutor", fields: [executedById], references: [id], onDelete: SetNull)
|
|
2987
|
+
|
|
2988
|
+
@@unique([runId, caseId])
|
|
2989
|
+
@@index([caseId])
|
|
2990
|
+
@@index([bugId])
|
|
2991
|
+
@@map("test_run_cases")
|
|
2992
|
+
@@index([execRunId])
|
|
2993
|
+
@@index([executedById])
|
|
2994
|
+
}
|
|
2995
|
+
|
|
2996
|
+
// AI 执行运行记录(MCP 认领-回报协议)
|
|
2997
|
+
model TestExecRun {
|
|
2998
|
+
id String @id @default(cuid())
|
|
2999
|
+
runCaseId String
|
|
3000
|
+
mode String @default("browser") // browser|api
|
|
3001
|
+
status String @default("claimed") // claimed|running|completed|failed|cancelled|timeout_reclaimed
|
|
3002
|
+
agentName String?
|
|
3003
|
+
report Json? // { perStep: [{ order, action, observed, verdict: pass|fail|uncertain, screenshotBlobId? }], consoleLog?: string[], networkLog?: string[], finalVerdict, confidence }
|
|
3004
|
+
error String? @db.Text
|
|
3005
|
+
claimedAt DateTime? @default(now())
|
|
3006
|
+
completedAt DateTime?
|
|
3007
|
+
createdAt DateTime @default(now())
|
|
3008
|
+
|
|
3009
|
+
runCase TestRunCase @relation("testExecHistory", fields: [runCaseId], references: [id], onDelete: Cascade)
|
|
3010
|
+
currentRunCases TestRunCase[] @relation("testExecCurrent")
|
|
3011
|
+
@@index([status, claimedAt])
|
|
3012
|
+
@@map("test_exec_runs")
|
|
3013
|
+
@@index([runCaseId])
|
|
3014
|
+
}
|
|
3015
|
+
|
|
3016
|
+
// AI 生成的自动化代码(E2E/单测;caseVersion 超过 case.version 即 stale)
|
|
3017
|
+
model TestAutomationArtifact {
|
|
3018
|
+
id String @id @default(cuid())
|
|
3019
|
+
caseId String
|
|
3020
|
+
caseVersion Int // 生成时的用例版本——case.version 超过它即 stale(UI 标「过期待重生成」,复跑排除)
|
|
3021
|
+
kind String // unit|e2e
|
|
3022
|
+
status String @default("draft") // draft|verified|adopted|rejected
|
|
3023
|
+
language String @default("typescript")
|
|
3024
|
+
code String @db.Text
|
|
3025
|
+
targetPath String?
|
|
3026
|
+
verifyRun Json? // { passed, failed, skipped, coverage?, logBlobId?, attempts, lastError? }
|
|
3027
|
+
createdById String
|
|
3028
|
+
createdAt DateTime @default(now())
|
|
3029
|
+
adoptedAt DateTime?
|
|
3030
|
+
|
|
3031
|
+
case TestCase @relation(fields: [caseId], references: [id], onDelete: Cascade)
|
|
3032
|
+
createdBy User @relation("testArtifactCreator", fields: [createdById], references: [id], onDelete: Cascade)
|
|
3033
|
+
@@index([caseId, kind])
|
|
3034
|
+
@@map("test_automation_artifacts")
|
|
3035
|
+
@@index([createdById])
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
// ==================== 协作模块(仅 PG schema,Yjs 多人协作 P1;规格 2026-10-07-yjs-multiplayer-collaboration §5.1 逐字) ====================
|
|
3039
|
+
|
|
3040
|
+
model CollabDocument {
|
|
3041
|
+
id String @id @default(cuid())
|
|
3042
|
+
roomName String @unique
|
|
3043
|
+
state Bytes // 合并后的 Yjs 全量快照(Y.encodeStateAsUpdate)
|
|
3044
|
+
updatedAt DateTime @updatedAt
|
|
3045
|
+
}
|
|
3046
|
+
model CollabUpdate { // 追加日志:版本历史/审计的数据源
|
|
3047
|
+
id String @id @default(cuid())
|
|
3048
|
+
roomName String
|
|
3049
|
+
update Bytes
|
|
3050
|
+
authorId String? // 由 CollabClient 映射解析,写日志时尽力归属
|
|
3051
|
+
createdAt DateTime @default(now())
|
|
3052
|
+
@@index([roomName, createdAt])
|
|
3053
|
+
}
|
|
3054
|
+
model CollabClient { // clientID → userId 连接期映射(R2 持久来源标记的根)
|
|
3055
|
+
id String @id @default(cuid())
|
|
3056
|
+
roomName String
|
|
3057
|
+
clientId BigInt // Yjs clientID(random.uint32,可达 2^32-1,超 Int32 上限必须 BigInt)
|
|
3058
|
+
userId String? // guest:* 为 null
|
|
3059
|
+
seenAt DateTime
|
|
3060
|
+
@@unique([roomName, clientId])
|
|
3061
|
+
}
|
|
3062
|
+
|
|
3063
|
+
// ==================== 任务模块(仅 PG schema,AiTask/AiTaskRun;规格 2026-10-09-task-module-design §4 逐字) ====================
|
|
3064
|
+
|
|
3065
|
+
model AiTask {
|
|
3066
|
+
id String @id @default(cuid())
|
|
3067
|
+
createdById String
|
|
3068
|
+
creator User @relation("aiTaskCreator", fields: [createdById], references: [id], onDelete: Cascade)
|
|
3069
|
+
workspaceId String?
|
|
3070
|
+
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: SetNull)
|
|
3071
|
+
projectId String?
|
|
3072
|
+
project Project? @relation(fields: [projectId], references: [id], onDelete: SetNull) // 仅执行上下文(项目名注入 prompt),不做权限边界;对齐 Story/Bug/TestCase 的 relation 惯例,项目删除自动置空
|
|
3073
|
+
title String @db.VarChar(200)
|
|
3074
|
+
instruction String @db.Text
|
|
3075
|
+
// —— 源型任务:从「分配给我的」条目发起时记录来源(多态引用,无 FK;ProjectActivity.targetType 同款先例)——
|
|
3076
|
+
sourceType String? // story | bug | testcase;null = 自由指令任务
|
|
3077
|
+
sourceId String?
|
|
3078
|
+
// 最近一次 run 的投影,供列表筛选;权威状态在 AiTaskRun
|
|
3079
|
+
status String @default("backlog") // backlog|running|completed|failed|canceled(canceled 为 P2 调度预留,P0 无写入方)
|
|
3080
|
+
lastRunAt DateTime?
|
|
3081
|
+
lastRunId String?
|
|
3082
|
+
// —— 调度预留(P2 启用)——
|
|
3083
|
+
scheduleCron String? // 5 字段 cron
|
|
3084
|
+
scheduleTimezone String? // IANA,默认 Asia/Shanghai
|
|
3085
|
+
maxRuns Int? // null = 不限
|
|
3086
|
+
runCount Int @default(0)
|
|
3087
|
+
nextRunAt DateTime? // P2 调度扫描 @@index
|
|
3088
|
+
createdAt DateTime @default(now())
|
|
3089
|
+
updatedAt DateTime @updatedAt
|
|
3090
|
+
runs AiTaskRun[]
|
|
3091
|
+
@@index([createdById, status])
|
|
3092
|
+
@@index([sourceType, sourceId])
|
|
3093
|
+
@@index([nextRunAt])
|
|
3094
|
+
@@map("ai_tasks")
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
model AiTaskRun {
|
|
3098
|
+
id String @id @default(cuid())
|
|
3099
|
+
taskId String
|
|
3100
|
+
task AiTask @relation(fields: [taskId], references: [id], onDelete: Cascade)
|
|
3101
|
+
trigger String @default("manual") // manual|schedule
|
|
3102
|
+
status String @default("running") // running|completed|failed|timeout|canceled(canceled 为 P2 预留,P0 无写入方)
|
|
3103
|
+
resultSummary String? @db.Text // markdown 结果
|
|
3104
|
+
error String? @db.Text
|
|
3105
|
+
parentRunId String? // runChat 审计链
|
|
3106
|
+
startedAt DateTime @default(now())
|
|
3107
|
+
finishedAt DateTime?
|
|
3108
|
+
durationMs Int?
|
|
3109
|
+
@@index([taskId, startedAt(sort: Desc)])
|
|
3110
|
+
@@map("ai_task_runs")
|
|
3111
|
+
}
|