@allbluecn/database 0.9.1 → 0.9.2
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/desktop-init.ts +2 -2
- package/dist/lib/share-utils.js +3 -3
- package/generated/browser.ts +115 -25
- package/generated/client.ts +115 -25
- package/generated/commonInputTypes.ts +34 -0
- package/generated/enums.ts +14 -0
- package/generated/internal/class.ts +234 -54
- package/generated/internal/prismaNamespace.ts +2190 -511
- package/generated/internal/prismaNamespaceBrowser.ts +391 -76
- package/generated/models/AgentConversation.ts +89 -89
- package/generated/models/AiProvider.ts +3 -3
- package/generated/models/AiStreamChunk.ts +3 -3
- 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 +5023 -0
- package/generated/models/BugActivity.ts +1765 -0
- package/generated/models/BugComment.ts +1853 -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/Comment.ts +99 -99
- package/generated/models/Component.ts +9 -9
- package/generated/models/ComponentInstance.ts +17 -17
- package/generated/models/CustomRole.ts +8 -8
- package/generated/models/Design.ts +2872 -0
- package/generated/models/DesignPage.ts +2402 -0
- package/generated/models/DesignTag.ts +1430 -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 +1970 -58
- 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/Tag.ts +49 -49
- package/generated/models/TestAutomationArtifact.ts +1790 -0
- package/generated/models/TestCase.ts +3568 -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 +12141 -2721
- package/generated/models.ts +26 -8
- package/generated-sqlite/browser.ts +8 -23
- package/generated-sqlite/client.ts +8 -23
- package/generated-sqlite/internal/class.ts +20 -50
- package/generated-sqlite/internal/prismaNamespace.ts +166 -437
- package/generated-sqlite/internal/prismaNamespaceBrowser.ts +25 -71
- 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 +9 -9
- package/generated-sqlite/models/ComponentInstance.ts +17 -17
- package/generated-sqlite/models/Design.ts +2679 -0
- package/generated-sqlite/models/DesignPage.ts +2398 -0
- package/generated-sqlite/models/DesignTag.ts +1426 -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/Tag.ts +49 -49
- package/generated-sqlite/models/User.ts +1201 -1321
- package/generated-sqlite/models/Workspace.ts +164 -0
- package/generated-sqlite/models.ts +4 -7
- package/index.ts +17 -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/package.json +2 -2
- package/schema.prisma +687 -177
- package/schema.sqlite.prisma +149 -151
- 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/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-sqlite/models/Artboard.ts +0 -1808
- package/generated-sqlite/models/ArtboardExport.ts +0 -1545
- 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/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,7 +62,7 @@ model User {
|
|
|
63
62
|
passwordResetTokens PasswordResetToken[]
|
|
64
63
|
emailVerificationTokens EmailVerificationToken[]
|
|
65
64
|
emailPreference EmailPreference?
|
|
66
|
-
|
|
65
|
+
designs Design[]
|
|
67
66
|
tags Tag[]
|
|
68
67
|
knowledgeBases KnowledgeBase[]
|
|
69
68
|
knowledgeDocuments KnowledgeDocument[]
|
|
@@ -78,12 +77,11 @@ model User {
|
|
|
78
77
|
anyhubMarketApps AnyHubMarketApp[]
|
|
79
78
|
reviewedAnyhubRecommendations AnyHubRecommendation[] @relation("reviewedAnyhubRecommendations")
|
|
80
79
|
anyhubRecommenders AnyHubRecommender[]
|
|
81
|
-
|
|
80
|
+
designVersions DesignVersion[]
|
|
82
81
|
reviewComments ReviewComment[]
|
|
83
82
|
comments Comment[]
|
|
84
83
|
commentIgnores CommentIgnore[]
|
|
85
84
|
reviews Review[] @relation("reviewer")
|
|
86
|
-
designProjects DesignProject[]
|
|
87
85
|
storiesCreated Story[] @relation("storyCreator")
|
|
88
86
|
storiesAssigned Story[] @relation("storyAssignee")
|
|
89
87
|
storiesEdited Story[] @relation("storyEditor")
|
|
@@ -123,8 +121,24 @@ model User {
|
|
|
123
121
|
harnessWorkspaces HarnessWorkspace[]
|
|
124
122
|
agentBindings BusinessAgentBinding[]
|
|
125
123
|
blobs Blob[]
|
|
124
|
+
bugsAssigned Bug[] @relation("bugAssignee")
|
|
125
|
+
bugsCreated Bug[] @relation("bugCreator")
|
|
126
|
+
bugsEdited Bug[] @relation("bugEditor")
|
|
127
|
+
bugActivities BugActivity[] @relation("bugActivityUser")
|
|
128
|
+
bugComments BugComment[] @relation("bugCommentUser")
|
|
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[]
|
|
126
138
|
|
|
127
139
|
@@map("users")
|
|
140
|
+
@@index([role])
|
|
141
|
+
@@index([status])
|
|
128
142
|
}
|
|
129
143
|
|
|
130
144
|
// OAuth 账号关联
|
|
@@ -158,7 +172,7 @@ model Project {
|
|
|
158
172
|
icon String @default("folder")
|
|
159
173
|
timezone String? // 项目时区,null = 跟随用户全局时区
|
|
160
174
|
ownerId String
|
|
161
|
-
owner User @relation("projectOwner", fields: [ownerId], references: [id])
|
|
175
|
+
owner User @relation("projectOwner", fields: [ownerId], references: [id], onDelete: Restrict)
|
|
162
176
|
workspaceId String?
|
|
163
177
|
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: SetNull)
|
|
164
178
|
members ProjectMember[]
|
|
@@ -167,6 +181,15 @@ model Project {
|
|
|
167
181
|
iterations Iteration[]
|
|
168
182
|
iterationAutoSchedule IterationAutoSchedule?
|
|
169
183
|
knowledgeBases ProjectKnowledgeBase[]
|
|
184
|
+
bugs Bug[]
|
|
185
|
+
accessTokens ProjectAccessToken[]
|
|
186
|
+
webhooks ProjectWebhook[]
|
|
187
|
+
bugSettings BugProjectSettings?
|
|
188
|
+
testCases TestCase[]
|
|
189
|
+
testCaseFolders TestCaseFolder[]
|
|
190
|
+
testGenerationRuns TestGenerationRun[]
|
|
191
|
+
testPlans TestPlan[]
|
|
192
|
+
testRuns TestRun[]
|
|
170
193
|
createdAt DateTime @default(now())
|
|
171
194
|
updatedAt DateTime @updatedAt
|
|
172
195
|
|
|
@@ -200,7 +223,7 @@ model Workspace {
|
|
|
200
223
|
description String?
|
|
201
224
|
pinnedToSidebar Boolean @default(false)
|
|
202
225
|
ownerId String
|
|
203
|
-
owner User @relation("workspaceOwner", fields: [ownerId], references: [id])
|
|
226
|
+
owner User @relation("workspaceOwner", fields: [ownerId], references: [id], onDelete: Restrict)
|
|
204
227
|
projects Project[]
|
|
205
228
|
members WorkspaceMember[]
|
|
206
229
|
knowledgeBases KnowledgeBase[]
|
|
@@ -292,6 +315,7 @@ model TeamJoinRequest {
|
|
|
292
315
|
@@unique([invitationId, email])
|
|
293
316
|
@@index([ownerId, status])
|
|
294
317
|
@@map("team_join_requests")
|
|
318
|
+
@@index([userId])
|
|
295
319
|
}
|
|
296
320
|
|
|
297
321
|
// 项目活动记录
|
|
@@ -309,6 +333,7 @@ model ProjectActivity {
|
|
|
309
333
|
|
|
310
334
|
@@index([projectId, createdAt])
|
|
311
335
|
@@map("project_activities")
|
|
336
|
+
@@index([userId])
|
|
312
337
|
}
|
|
313
338
|
|
|
314
339
|
// 对话线程(作为 TanStack AI persistence threadId)
|
|
@@ -327,12 +352,14 @@ model ChatThread {
|
|
|
327
352
|
interrupts ChatInterrupt[]
|
|
328
353
|
generations GenerationRun[]
|
|
329
354
|
agentId String?
|
|
330
|
-
agent UserAgent? @relation(fields: [agentId], references: [id])
|
|
355
|
+
agent UserAgent? @relation(fields: [agentId], references: [id], onDelete: SetNull)
|
|
331
356
|
workspaceId String?
|
|
332
357
|
workspace HarnessWorkspace? @relation(fields: [workspaceId], references: [id], onDelete: SetNull)
|
|
333
358
|
|
|
334
359
|
@@index([userId, updatedAt])
|
|
335
360
|
@@map("chat_threads")
|
|
361
|
+
@@index([agentId])
|
|
362
|
+
@@index([workspaceId])
|
|
336
363
|
}
|
|
337
364
|
|
|
338
365
|
// 对话消息(TanStack AI messages store)
|
|
@@ -404,7 +431,7 @@ model ChatInterrupt {
|
|
|
404
431
|
model ChatPersistenceMeta {
|
|
405
432
|
namespace String
|
|
406
433
|
key String
|
|
407
|
-
value Json
|
|
434
|
+
value Json @default("{}")
|
|
408
435
|
updatedAt DateTime @updatedAt
|
|
409
436
|
|
|
410
437
|
@@unique([namespace, key])
|
|
@@ -463,7 +490,7 @@ model SystemPromptVersion {
|
|
|
463
490
|
templateId String
|
|
464
491
|
template SystemPromptTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
|
465
492
|
version Int
|
|
466
|
-
sections Json
|
|
493
|
+
sections Json @default("[]")
|
|
467
494
|
note String?
|
|
468
495
|
createdBy String?
|
|
469
496
|
createdAt DateTime @default(now())
|
|
@@ -491,6 +518,7 @@ model BusinessAgentBinding {
|
|
|
491
518
|
@@unique([userId, bizKey])
|
|
492
519
|
@@index([userId])
|
|
493
520
|
@@map("business_agent_bindings")
|
|
521
|
+
@@index([agentId])
|
|
494
522
|
}
|
|
495
523
|
|
|
496
524
|
// 媒体生成记录(占位,本轮建表不接入业务)
|
|
@@ -534,6 +562,8 @@ model LoginLog {
|
|
|
534
562
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
535
563
|
|
|
536
564
|
@@map("login_logs")
|
|
565
|
+
@@index([userId])
|
|
566
|
+
@@index([createdAt])
|
|
537
567
|
}
|
|
538
568
|
|
|
539
569
|
// 邀请码
|
|
@@ -544,6 +574,10 @@ model InvitationCode {
|
|
|
544
574
|
usedCount Int @default(0)
|
|
545
575
|
expiresAt DateTime
|
|
546
576
|
createdAt DateTime @default(now())
|
|
577
|
+
// DB-13 决策:保留不删、暂不加 FK。原判「悬空列」不实——admin invitations
|
|
578
|
+
// 写入 createdById(session.user.id)并按 id 联表展示创建者,删除前置条件
|
|
579
|
+
// 「0 引用」不成立;存量数据未清洗,直接加 FK 有约束创建失败风险。
|
|
580
|
+
// 后续任务:回填清洗(孤儿置 null)→ 加 relation + SetNull + 索引。
|
|
547
581
|
createdById String?
|
|
548
582
|
disabledAt DateTime?
|
|
549
583
|
|
|
@@ -563,6 +597,8 @@ model InvitationUse {
|
|
|
563
597
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
564
598
|
|
|
565
599
|
@@map("invitation_uses")
|
|
600
|
+
@@index([codeId])
|
|
601
|
+
@@index([userId])
|
|
566
602
|
}
|
|
567
603
|
|
|
568
604
|
// 密码重置令牌
|
|
@@ -577,6 +613,7 @@ model PasswordResetToken {
|
|
|
577
613
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
578
614
|
|
|
579
615
|
@@map("password_reset_tokens")
|
|
616
|
+
@@index([userId])
|
|
580
617
|
}
|
|
581
618
|
|
|
582
619
|
// 邮箱验证令牌
|
|
@@ -591,6 +628,7 @@ model EmailVerificationToken {
|
|
|
591
628
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
592
629
|
|
|
593
630
|
@@map("email_verification_tokens")
|
|
631
|
+
@@index([userId])
|
|
594
632
|
}
|
|
595
633
|
|
|
596
634
|
// 出站邮件日志
|
|
@@ -745,15 +783,17 @@ model KnowledgeDocument {
|
|
|
745
783
|
@@index([parentId])
|
|
746
784
|
@@index([kbId, isHomepage])
|
|
747
785
|
@@map("knowledge_documents")
|
|
786
|
+
@@index([createdBy])
|
|
748
787
|
}
|
|
749
788
|
|
|
750
|
-
//
|
|
751
|
-
model
|
|
789
|
+
// Design 文档表
|
|
790
|
+
model Design {
|
|
752
791
|
id String @id @default(cuid())
|
|
753
792
|
icon String @default("file") // 图标名称
|
|
754
|
-
name String //
|
|
793
|
+
name String // Design 名称
|
|
755
794
|
description String? // 介绍
|
|
756
|
-
|
|
795
|
+
kind String @default("doc") // 板块合并:doc=文档型,canvas=画板型
|
|
796
|
+
settings Json? @default("{}") // 文档设置(布局、主题等)
|
|
757
797
|
userId String // 所属用户
|
|
758
798
|
isDeleted Boolean @default(false)
|
|
759
799
|
deletedAt DateTime?
|
|
@@ -761,33 +801,33 @@ model PRD {
|
|
|
761
801
|
updatedAt DateTime @updatedAt
|
|
762
802
|
|
|
763
803
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
764
|
-
pages
|
|
765
|
-
versions
|
|
804
|
+
pages DesignPage[]
|
|
805
|
+
versions DesignVersion[]
|
|
766
806
|
reviews Review[]
|
|
767
807
|
comments Comment[]
|
|
768
808
|
shares Share[]
|
|
769
|
-
|
|
809
|
+
designTags DesignTag[]
|
|
770
810
|
agentConversations AgentConversation[]
|
|
771
|
-
linkedStories
|
|
811
|
+
linkedStories StoryDesignLink[] @relation("DesignStoryLinks")
|
|
772
812
|
|
|
773
813
|
@@index([userId])
|
|
774
|
-
@@map("
|
|
814
|
+
@@map("designs")
|
|
775
815
|
}
|
|
776
816
|
|
|
777
817
|
// Agent 原型生成会话
|
|
778
818
|
model AgentConversation {
|
|
779
819
|
id String @id @default(cuid())
|
|
780
820
|
userId String
|
|
781
|
-
|
|
821
|
+
designId String
|
|
782
822
|
title String @default("新会话")
|
|
783
823
|
createdAt DateTime @default(now())
|
|
784
824
|
updatedAt DateTime @updatedAt
|
|
785
825
|
|
|
786
826
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
787
|
-
|
|
827
|
+
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
788
828
|
messages AgentMessage[]
|
|
789
829
|
|
|
790
|
-
@@index([userId,
|
|
830
|
+
@@index([userId, designId])
|
|
791
831
|
@@map("agent_conversations")
|
|
792
832
|
}
|
|
793
833
|
|
|
@@ -819,7 +859,7 @@ model Component {
|
|
|
819
859
|
defaultWidth Int @default(200)
|
|
820
860
|
defaultHeight Int @default(40)
|
|
821
861
|
prototypeKey String? // unique key for registry lookup (e.g. "text", "button")
|
|
822
|
-
config Json // 属性描述 schema(props定义、slots、events)
|
|
862
|
+
config Json @default("{}") // 属性描述 schema(props定义、slots、events)
|
|
823
863
|
defaultProps Json? // 默认属性值
|
|
824
864
|
defaultStyle Json? // 默认样式
|
|
825
865
|
preview String? // 预览图URL
|
|
@@ -876,9 +916,11 @@ model BlockComponent {
|
|
|
876
916
|
styleOverride Json? // 局部覆写样式
|
|
877
917
|
|
|
878
918
|
block Block @relation(fields: [blockId], references: [id], onDelete: Cascade)
|
|
879
|
-
component Component @relation("componentRef", fields: [componentId], references: [id])
|
|
919
|
+
component Component @relation("componentRef", fields: [componentId], references: [id], onDelete: Cascade)
|
|
880
920
|
|
|
881
921
|
@@map("block_components")
|
|
922
|
+
@@index([blockId])
|
|
923
|
+
@@index([componentId])
|
|
882
924
|
}
|
|
883
925
|
|
|
884
926
|
// 模板定义表(后台维护)
|
|
@@ -909,34 +951,37 @@ model TemplateBlock {
|
|
|
909
951
|
height Float?
|
|
910
952
|
|
|
911
953
|
template Template @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
|
912
|
-
block Block @relation("templateBlockRef", fields: [blockId], references: [id])
|
|
954
|
+
block Block @relation("templateBlockRef", fields: [blockId], references: [id], onDelete: Cascade)
|
|
913
955
|
|
|
914
956
|
@@map("template_blocks")
|
|
957
|
+
@@index([templateId])
|
|
958
|
+
@@index([blockId])
|
|
915
959
|
}
|
|
916
960
|
|
|
917
|
-
//
|
|
918
|
-
model
|
|
961
|
+
// Design 页面/目录树节点
|
|
962
|
+
model DesignPage {
|
|
919
963
|
id String @id @default(cuid())
|
|
920
|
-
|
|
964
|
+
designId String
|
|
921
965
|
parentId String? // 父节点,构建树形结构(null = 根级)
|
|
922
966
|
name String
|
|
923
967
|
order Int @default(0) // 排序
|
|
924
968
|
type String @default("page") // "page" | "folder"
|
|
925
969
|
canvas Json? // 原型画板数据
|
|
926
|
-
content Json? //
|
|
970
|
+
content Json? // Design 文档内容
|
|
927
971
|
version Int @default(1) // 页面版本号
|
|
928
972
|
createdAt DateTime @default(now())
|
|
929
973
|
updatedAt DateTime @updatedAt
|
|
930
974
|
|
|
931
|
-
|
|
932
|
-
parent
|
|
933
|
-
children
|
|
975
|
+
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
976
|
+
parent DesignPage? @relation("PageHierarchy", fields: [parentId], references: [id], onDelete: Cascade)
|
|
977
|
+
children DesignPage[] @relation("PageHierarchy")
|
|
934
978
|
componentInstances ComponentInstance[]
|
|
935
979
|
blockInstances BlockInstance[]
|
|
936
980
|
pageVersions PageVersion[]
|
|
937
981
|
|
|
938
|
-
@@index([
|
|
939
|
-
@@map("
|
|
982
|
+
@@index([designId, order])
|
|
983
|
+
@@map("design_pages")
|
|
984
|
+
@@index([parentId])
|
|
940
985
|
}
|
|
941
986
|
|
|
942
987
|
// 组件实例(画布上)
|
|
@@ -956,12 +1001,14 @@ model ComponentInstance {
|
|
|
956
1001
|
createdAt DateTime @default(now())
|
|
957
1002
|
updatedAt DateTime @updatedAt
|
|
958
1003
|
|
|
959
|
-
page
|
|
960
|
-
component Component? @relation("componentRef", fields: [componentId], references: [id])
|
|
961
|
-
blockInstance BlockInstance? @relation(fields: [blockInstanceId], references: [id])
|
|
1004
|
+
page DesignPage @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
|
1005
|
+
component Component? @relation("componentRef", fields: [componentId], references: [id], onDelete: SetNull)
|
|
1006
|
+
blockInstance BlockInstance? @relation(fields: [blockInstanceId], references: [id], onDelete: SetNull)
|
|
962
1007
|
|
|
963
1008
|
@@index([pageId])
|
|
964
1009
|
@@map("component_instances")
|
|
1010
|
+
@@index([componentId])
|
|
1011
|
+
@@index([blockInstanceId])
|
|
965
1012
|
}
|
|
966
1013
|
|
|
967
1014
|
// 区块实例(画布上)
|
|
@@ -980,37 +1027,40 @@ model BlockInstance {
|
|
|
980
1027
|
createdAt DateTime @default(now())
|
|
981
1028
|
updatedAt DateTime @updatedAt
|
|
982
1029
|
|
|
983
|
-
page
|
|
984
|
-
block Block? @relation("blockRef", fields: [blockId], references: [id])
|
|
1030
|
+
page DesignPage @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
|
1031
|
+
block Block? @relation("blockRef", fields: [blockId], references: [id], onDelete: SetNull)
|
|
985
1032
|
instances ComponentInstance[]
|
|
986
1033
|
|
|
987
1034
|
@@index([pageId])
|
|
988
1035
|
@@map("block_instances")
|
|
1036
|
+
@@index([blockId])
|
|
989
1037
|
}
|
|
990
1038
|
|
|
991
|
-
//
|
|
992
|
-
model
|
|
1039
|
+
// Design 版本(手动发布创建)
|
|
1040
|
+
model DesignVersion {
|
|
993
1041
|
id String @id @default(cuid())
|
|
994
|
-
|
|
1042
|
+
designId String
|
|
995
1043
|
major Int @default(1)
|
|
996
1044
|
minor Int @default(0)
|
|
997
1045
|
patch Int @default(0)
|
|
998
1046
|
versionLabel String // 如 "v1", "v1.1", "v1.1.1"
|
|
999
1047
|
parentVersion String? // 上一版本ID(版本链)
|
|
1000
|
-
pageVersions Json // [{ pageId, pageName, version, canvas, content }]
|
|
1048
|
+
pageVersions Json @default("[]") // [{ pageId, pageName, version, canvas, content }]
|
|
1001
1049
|
notes String? // 发版说明
|
|
1002
1050
|
userId String
|
|
1003
1051
|
createdAt DateTime @default(now())
|
|
1004
1052
|
updatedAt DateTime?
|
|
1005
1053
|
|
|
1006
|
-
|
|
1007
|
-
|
|
1054
|
+
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
1055
|
+
// 产品决策(审查修复):Restrict——版本归属共享 Design 而非创建者个人,删创建者
|
|
1056
|
+
// 级联删版本会经 Review.version/ReviewComment/ShareVersion 销毁他人数据。
|
|
1057
|
+
user User @relation(fields: [userId], references: [id], onDelete: Restrict)
|
|
1008
1058
|
reviews Review[]
|
|
1009
1059
|
shareVersions ShareVersion[]
|
|
1010
1060
|
|
|
1011
|
-
@@index([
|
|
1061
|
+
@@index([designId, createdAt])
|
|
1012
1062
|
@@index([userId])
|
|
1013
|
-
@@map("
|
|
1063
|
+
@@map("design_versions")
|
|
1014
1064
|
}
|
|
1015
1065
|
|
|
1016
1066
|
// 页面版本(独立的页面级别版本历史)
|
|
@@ -1019,13 +1069,13 @@ model PageVersion {
|
|
|
1019
1069
|
pageId String
|
|
1020
1070
|
version Int // 整数版本号,自增
|
|
1021
1071
|
notes String? // 版本说明(用户可编辑)
|
|
1022
|
-
canvas Json? // 原型快照
|
|
1072
|
+
canvas Json? @default("{}") // 原型快照
|
|
1023
1073
|
content Json? // 文档快照
|
|
1024
1074
|
restoredFromVersion Int? // 从哪个版本号还原而来(null 表示非还原版本)
|
|
1025
|
-
|
|
1075
|
+
fromDesignVersionId String? // 来源:从哪个 Design 版本创建(可选标记)
|
|
1026
1076
|
createdAt DateTime @default(now())
|
|
1027
1077
|
|
|
1028
|
-
page
|
|
1078
|
+
page DesignPage @relation(fields: [pageId], references: [id], onDelete: Cascade)
|
|
1029
1079
|
|
|
1030
1080
|
@@index([pageId, createdAt])
|
|
1031
1081
|
@@index([pageId, version])
|
|
@@ -1035,7 +1085,7 @@ model PageVersion {
|
|
|
1035
1085
|
// 评审工作流
|
|
1036
1086
|
model Review {
|
|
1037
1087
|
id String @id @default(cuid())
|
|
1038
|
-
|
|
1088
|
+
designId String
|
|
1039
1089
|
versionId String
|
|
1040
1090
|
status ReviewStatus @default(PENDING)
|
|
1041
1091
|
reviewerId String?
|
|
@@ -1043,13 +1093,13 @@ model Review {
|
|
|
1043
1093
|
createdAt DateTime @default(now())
|
|
1044
1094
|
completedAt DateTime?
|
|
1045
1095
|
|
|
1046
|
-
|
|
1047
|
-
version
|
|
1048
|
-
reviewer User? @relation("reviewer", fields: [reviewerId], references: [id])
|
|
1096
|
+
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
1097
|
+
version DesignVersion @relation(fields: [versionId], references: [id], onDelete: Cascade)
|
|
1098
|
+
reviewer User? @relation("reviewer", fields: [reviewerId], references: [id], onDelete: SetNull)
|
|
1049
1099
|
comments ReviewComment[]
|
|
1050
1100
|
|
|
1051
|
-
@@unique([
|
|
1052
|
-
@@index([
|
|
1101
|
+
@@unique([designId, versionId])
|
|
1102
|
+
@@index([designId])
|
|
1053
1103
|
@@index([versionId])
|
|
1054
1104
|
@@index([reviewerId])
|
|
1055
1105
|
@@map("reviews")
|
|
@@ -1067,8 +1117,8 @@ model ReviewComment {
|
|
|
1067
1117
|
createdAt DateTime @default(now())
|
|
1068
1118
|
|
|
1069
1119
|
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])
|
|
1120
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1121
|
+
parent ReviewComment? @relation("ReviewCommentReplies", fields: [parentId], references: [id], onDelete: SetNull)
|
|
1072
1122
|
replies ReviewComment[] @relation("ReviewCommentReplies")
|
|
1073
1123
|
|
|
1074
1124
|
@@index([reviewId])
|
|
@@ -1077,10 +1127,10 @@ model ReviewComment {
|
|
|
1077
1127
|
@@map("review_comments")
|
|
1078
1128
|
}
|
|
1079
1129
|
|
|
1080
|
-
// 评论(
|
|
1130
|
+
// 评论(Design 级别 / 页面级别 / 元素级别)
|
|
1081
1131
|
model Comment {
|
|
1082
1132
|
id String @id @default(cuid())
|
|
1083
|
-
|
|
1133
|
+
designId String
|
|
1084
1134
|
pageId String? // 可选:针对某页面
|
|
1085
1135
|
elementId String? // 可选:针对某元素(组件/区块实例ID)
|
|
1086
1136
|
userId String
|
|
@@ -1091,13 +1141,13 @@ model Comment {
|
|
|
1091
1141
|
createdAt DateTime @default(now())
|
|
1092
1142
|
updatedAt DateTime @updatedAt
|
|
1093
1143
|
|
|
1094
|
-
|
|
1095
|
-
user User @relation(fields: [userId], references: [id])
|
|
1096
|
-
parent Comment? @relation("CommentReplies", fields: [parentId], references: [id])
|
|
1144
|
+
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
1145
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1146
|
+
parent Comment? @relation("CommentReplies", fields: [parentId], references: [id], onDelete: SetNull)
|
|
1097
1147
|
replies Comment[] @relation("CommentReplies")
|
|
1098
1148
|
ignores CommentIgnore[]
|
|
1099
1149
|
|
|
1100
|
-
@@index([
|
|
1150
|
+
@@index([designId])
|
|
1101
1151
|
@@index([userId])
|
|
1102
1152
|
@@index([parentId])
|
|
1103
1153
|
@@index([pageId])
|
|
@@ -1110,8 +1160,8 @@ model CommentIgnore {
|
|
|
1110
1160
|
commentId String
|
|
1111
1161
|
createdAt DateTime @default(now())
|
|
1112
1162
|
|
|
1113
|
-
user User @relation(fields: [userId], references: [id])
|
|
1114
|
-
comment Comment @relation(fields: [commentId], references: [id])
|
|
1163
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1164
|
+
comment Comment @relation(fields: [commentId], references: [id], onDelete: Cascade)
|
|
1115
1165
|
|
|
1116
1166
|
@@unique([userId, commentId])
|
|
1117
1167
|
@@index([userId])
|
|
@@ -1122,7 +1172,7 @@ model CommentIgnore {
|
|
|
1122
1172
|
// 分享链接
|
|
1123
1173
|
model Share {
|
|
1124
1174
|
id String @id @default(cuid())
|
|
1125
|
-
|
|
1175
|
+
designId String
|
|
1126
1176
|
token String @unique
|
|
1127
1177
|
type String @default("prd") // "prd" | 预留扩展
|
|
1128
1178
|
status ShareStatus @default(ACTIVE)
|
|
@@ -1132,11 +1182,11 @@ model Share {
|
|
|
1132
1182
|
createdAt DateTime @default(now())
|
|
1133
1183
|
updatedAt DateTime @updatedAt
|
|
1134
1184
|
|
|
1135
|
-
|
|
1185
|
+
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
1136
1186
|
shareVersions ShareVersion[]
|
|
1137
1187
|
|
|
1138
1188
|
@@index([token])
|
|
1139
|
-
@@index([
|
|
1189
|
+
@@index([designId, type, status])
|
|
1140
1190
|
@@index([status])
|
|
1141
1191
|
@@index([expiresAt])
|
|
1142
1192
|
@@map("shares")
|
|
@@ -1154,7 +1204,7 @@ model Tag {
|
|
|
1154
1204
|
updatedAt DateTime @updatedAt
|
|
1155
1205
|
|
|
1156
1206
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1157
|
-
|
|
1207
|
+
designTags DesignTag[]
|
|
1158
1208
|
|
|
1159
1209
|
@@unique([name, userId])
|
|
1160
1210
|
@@index([sortOrder])
|
|
@@ -1162,20 +1212,20 @@ model Tag {
|
|
|
1162
1212
|
@@map("tags")
|
|
1163
1213
|
}
|
|
1164
1214
|
|
|
1165
|
-
//
|
|
1166
|
-
model
|
|
1215
|
+
// Design-标签多对多
|
|
1216
|
+
model DesignTag {
|
|
1167
1217
|
id String @id @default(cuid())
|
|
1168
|
-
|
|
1218
|
+
designId String
|
|
1169
1219
|
tagId String
|
|
1170
1220
|
createdAt DateTime @default(now())
|
|
1171
1221
|
|
|
1172
|
-
|
|
1222
|
+
design Design @relation(fields: [designId], references: [id], onDelete: Cascade)
|
|
1173
1223
|
tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
|
|
1174
1224
|
|
|
1175
|
-
@@unique([
|
|
1176
|
-
@@index([
|
|
1225
|
+
@@unique([designId, tagId])
|
|
1226
|
+
@@index([designId])
|
|
1177
1227
|
@@index([tagId])
|
|
1178
|
-
@@map("
|
|
1228
|
+
@@map("design_tags")
|
|
1179
1229
|
}
|
|
1180
1230
|
|
|
1181
1231
|
// 组件-标签多对多
|
|
@@ -1212,7 +1262,7 @@ model ShareVersion {
|
|
|
1212
1262
|
versionId String
|
|
1213
1263
|
|
|
1214
1264
|
share Share @relation(fields: [shareId], references: [id], onDelete: Cascade)
|
|
1215
|
-
version
|
|
1265
|
+
version DesignVersion @relation(fields: [versionId], references: [id], onDelete: Cascade)
|
|
1216
1266
|
|
|
1217
1267
|
@@unique([shareId, versionId])
|
|
1218
1268
|
@@index([shareId])
|
|
@@ -1274,7 +1324,7 @@ model AnyHubMarketApp {
|
|
|
1274
1324
|
category String?
|
|
1275
1325
|
tags String? @db.Text
|
|
1276
1326
|
downloads Int @default(0)
|
|
1277
|
-
capabilities Json
|
|
1327
|
+
capabilities Json @default("{}")
|
|
1278
1328
|
status MarketplaceAppStatus @default(DRAFT)
|
|
1279
1329
|
publishedAt DateTime?
|
|
1280
1330
|
userId String
|
|
@@ -1282,11 +1332,12 @@ model AnyHubMarketApp {
|
|
|
1282
1332
|
createdAt DateTime @default(now())
|
|
1283
1333
|
updatedAt DateTime @updatedAt
|
|
1284
1334
|
|
|
1285
|
-
user User @relation(fields: [userId], references: [id])
|
|
1286
|
-
recommendation AnyHubRecommendation? @relation("anyhubRecommendation", fields: [recommendationId], references: [id])
|
|
1335
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
1336
|
+
recommendation AnyHubRecommendation? @relation("anyhubRecommendation", fields: [recommendationId], references: [id], onDelete: SetNull)
|
|
1287
1337
|
|
|
1288
1338
|
@@index([status])
|
|
1289
1339
|
@@index([category])
|
|
1340
|
+
@@index([userId])
|
|
1290
1341
|
}
|
|
1291
1342
|
|
|
1292
1343
|
model AnyHubRecommendation {
|
|
@@ -1303,10 +1354,11 @@ model AnyHubRecommendation {
|
|
|
1303
1354
|
updatedAt DateTime @updatedAt
|
|
1304
1355
|
|
|
1305
1356
|
marketplaceApp AnyHubMarketApp? @relation("anyhubRecommendation")
|
|
1306
|
-
reviewer User? @relation("reviewedAnyhubRecommendations", fields: [reviewedBy], references: [id])
|
|
1357
|
+
reviewer User? @relation("reviewedAnyhubRecommendations", fields: [reviewedBy], references: [id], onDelete: SetNull)
|
|
1307
1358
|
recommenders AnyHubRecommender[]
|
|
1308
1359
|
|
|
1309
1360
|
@@index([status])
|
|
1361
|
+
@@index([reviewedBy])
|
|
1310
1362
|
}
|
|
1311
1363
|
|
|
1312
1364
|
model AnyHubRecommender {
|
|
@@ -1323,58 +1375,6 @@ model AnyHubRecommender {
|
|
|
1323
1375
|
}
|
|
1324
1376
|
|
|
1325
1377
|
// 设计稿
|
|
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
1378
|
// AI 服务商元数据(admin 维护)
|
|
1379
1379
|
model AiProvider {
|
|
1380
1380
|
id String @id @default(cuid())
|
|
@@ -1393,7 +1393,7 @@ model AiProvider {
|
|
|
1393
1393
|
badge String? // 卡片角标文案(如「推荐」「热门」「NEW」),admin 可配
|
|
1394
1394
|
isLocal Boolean @default(false)
|
|
1395
1395
|
enabled Boolean @default(true) // 平台级开关:停用后未配置用户看不到,已配置用户继续可用
|
|
1396
|
-
models Json // AiModelMeta[](admin 可编辑)
|
|
1396
|
+
models Json @default("[]") // AiModelMeta[](admin 可编辑)
|
|
1397
1397
|
sortOrder Int @default(0)
|
|
1398
1398
|
createdAt DateTime @default(now())
|
|
1399
1399
|
updatedAt DateTime @updatedAt
|
|
@@ -1433,7 +1433,7 @@ model ThirdPartyDependency {
|
|
|
1433
1433
|
displayName String? // 展示名(默认取 name)
|
|
1434
1434
|
description String? @db.Text // 依赖用途说明(admin 可编辑)
|
|
1435
1435
|
homepage String? // 官网 / 仓库
|
|
1436
|
-
category
|
|
1436
|
+
category DependencyCategory @default(other) // 值集与 kernel DependencyCategory 对齐(含 auth)
|
|
1437
1437
|
isWatched Boolean @default(true) // 是否置顶「关注列表」
|
|
1438
1438
|
priority String @default("normal") // high|normal|low
|
|
1439
1439
|
latestVersion String? // 缓存的 npm registry latest 版本
|
|
@@ -1629,13 +1629,16 @@ model Story {
|
|
|
1629
1629
|
startDate DateTime?
|
|
1630
1630
|
targetDate DateTime?
|
|
1631
1631
|
createdById String
|
|
1632
|
-
createdBy User @relation("storyCreator", fields: [createdById], references: [id])
|
|
1632
|
+
createdBy User @relation("storyCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
1633
1633
|
updatedById String?
|
|
1634
1634
|
updatedBy User? @relation("storyEditor", fields: [updatedById], references: [id], onDelete: SetNull)
|
|
1635
1635
|
labels StoryLabel[]
|
|
1636
1636
|
activities StoryActivity[]
|
|
1637
1637
|
comments StoryComment[]
|
|
1638
1638
|
reactions StoryReaction[]
|
|
1639
|
+
bugs Bug[]
|
|
1640
|
+
testCases TestCase[]
|
|
1641
|
+
generationRuns TestGenerationRun[]
|
|
1639
1642
|
createdAt DateTime @default(now())
|
|
1640
1643
|
updatedAt DateTime @updatedAt
|
|
1641
1644
|
|
|
@@ -1646,7 +1649,7 @@ model Story {
|
|
|
1646
1649
|
dependenciesAsTarget StoryDependency[] @relation("DependencyTarget")
|
|
1647
1650
|
links StoryLink[]
|
|
1648
1651
|
attachments StoryAttachment[]
|
|
1649
|
-
linkedPrds
|
|
1652
|
+
linkedPrds StoryDesignLink[] @relation("StoryDesignLinks")
|
|
1650
1653
|
linkedDocs StoryDocLink[] @relation("StoryDocLinks")
|
|
1651
1654
|
linkedExternalDocs StoryExternalLink[] @relation("StoryExternalLinks")
|
|
1652
1655
|
iterationId String?
|
|
@@ -1660,6 +1663,9 @@ model Story {
|
|
|
1660
1663
|
@@index([assigneeId])
|
|
1661
1664
|
@@index([createdById])
|
|
1662
1665
|
@@map("stories")
|
|
1666
|
+
@@index([updatedById])
|
|
1667
|
+
@@index([parentId])
|
|
1668
|
+
@@index([iterationId])
|
|
1663
1669
|
}
|
|
1664
1670
|
|
|
1665
1671
|
// 全局标签
|
|
@@ -1668,11 +1674,13 @@ model Label {
|
|
|
1668
1674
|
name String @unique
|
|
1669
1675
|
color String @default("#6b7280")
|
|
1670
1676
|
createdById String
|
|
1671
|
-
createdBy User @relation("labelCreator", fields: [createdById], references: [id])
|
|
1677
|
+
createdBy User @relation("labelCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
1672
1678
|
stories StoryLabel[]
|
|
1679
|
+
bugLabels BugLabel[]
|
|
1673
1680
|
createdAt DateTime @default(now())
|
|
1674
1681
|
|
|
1675
1682
|
@@map("labels")
|
|
1683
|
+
@@index([createdById])
|
|
1676
1684
|
}
|
|
1677
1685
|
|
|
1678
1686
|
model StoryLabel {
|
|
@@ -1684,6 +1692,7 @@ model StoryLabel {
|
|
|
1684
1692
|
@@id([storyId, labelId])
|
|
1685
1693
|
@@index([labelId])
|
|
1686
1694
|
@@map("story_labels")
|
|
1695
|
+
@@index([storyId])
|
|
1687
1696
|
}
|
|
1688
1697
|
|
|
1689
1698
|
model StoryActivity {
|
|
@@ -1691,7 +1700,7 @@ model StoryActivity {
|
|
|
1691
1700
|
storyId String
|
|
1692
1701
|
story Story @relation(fields: [storyId], references: [id], onDelete: Cascade)
|
|
1693
1702
|
userId String
|
|
1694
|
-
user User @relation("storyActivityUser", fields: [userId], references: [id])
|
|
1703
|
+
user User @relation("storyActivityUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
1695
1704
|
action String
|
|
1696
1705
|
field String?
|
|
1697
1706
|
oldValue String? @db.Text
|
|
@@ -1702,6 +1711,7 @@ model StoryActivity {
|
|
|
1702
1711
|
|
|
1703
1712
|
@@index([storyId, createdAt])
|
|
1704
1713
|
@@map("story_activities")
|
|
1714
|
+
@@index([userId])
|
|
1705
1715
|
}
|
|
1706
1716
|
|
|
1707
1717
|
model SequenceCounter {
|
|
@@ -1717,7 +1727,7 @@ model StoryComment {
|
|
|
1717
1727
|
storyId String
|
|
1718
1728
|
story Story @relation(fields: [storyId], references: [id], onDelete: Cascade)
|
|
1719
1729
|
userId String
|
|
1720
|
-
user User @relation("storyCommentUser", fields: [userId], references: [id])
|
|
1730
|
+
user User @relation("storyCommentUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
1721
1731
|
parentId String?
|
|
1722
1732
|
parent StoryComment? @relation("CommentReply", fields: [parentId], references: [id], onDelete: Cascade)
|
|
1723
1733
|
replies StoryComment[] @relation("CommentReply")
|
|
@@ -1729,6 +1739,7 @@ model StoryComment {
|
|
|
1729
1739
|
@@index([storyId, createdAt])
|
|
1730
1740
|
@@index([parentId])
|
|
1731
1741
|
@@map("story_comments")
|
|
1742
|
+
@@index([userId])
|
|
1732
1743
|
}
|
|
1733
1744
|
|
|
1734
1745
|
model StoryReaction {
|
|
@@ -1736,7 +1747,7 @@ model StoryReaction {
|
|
|
1736
1747
|
storyId String
|
|
1737
1748
|
story Story @relation(fields: [storyId], references: [id], onDelete: Cascade)
|
|
1738
1749
|
userId String
|
|
1739
|
-
user User @relation("storyReactionUser", fields: [userId], references: [id])
|
|
1750
|
+
user User @relation("storyReactionUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
1740
1751
|
emoji String
|
|
1741
1752
|
createdAt DateTime @default(now())
|
|
1742
1753
|
|
|
@@ -1750,7 +1761,7 @@ model CommentReaction {
|
|
|
1750
1761
|
commentId String
|
|
1751
1762
|
comment StoryComment @relation(fields: [commentId], references: [id], onDelete: Cascade)
|
|
1752
1763
|
userId String
|
|
1753
|
-
user User @relation("commentReactionUser", fields: [userId], references: [id])
|
|
1764
|
+
user User @relation("commentReactionUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
1754
1765
|
emoji String
|
|
1755
1766
|
createdAt DateTime @default(now())
|
|
1756
1767
|
|
|
@@ -1831,6 +1842,7 @@ model WorkspaceQuickDoc {
|
|
|
1831
1842
|
@@index([workspaceId])
|
|
1832
1843
|
@@index([workspaceId, docId])
|
|
1833
1844
|
@@map("workspace_quick_docs")
|
|
1845
|
+
@@index([createdBy])
|
|
1834
1846
|
}
|
|
1835
1847
|
|
|
1836
1848
|
model StoryLink {
|
|
@@ -1867,19 +1879,19 @@ model StoryAttachment {
|
|
|
1867
1879
|
@@map("story_attachments")
|
|
1868
1880
|
}
|
|
1869
1881
|
|
|
1870
|
-
model
|
|
1882
|
+
model StoryDesignLink {
|
|
1871
1883
|
id String @id @default(cuid())
|
|
1872
1884
|
storyId String
|
|
1873
|
-
|
|
1885
|
+
designId String
|
|
1874
1886
|
createdAt DateTime @default(now())
|
|
1875
1887
|
|
|
1876
|
-
story Story @relation("
|
|
1877
|
-
|
|
1888
|
+
story Story @relation("StoryDesignLinks", fields: [storyId], references: [id], onDelete: Cascade)
|
|
1889
|
+
design Design @relation("DesignStoryLinks", fields: [designId], references: [id], onDelete: Cascade)
|
|
1878
1890
|
|
|
1879
|
-
@@unique([storyId,
|
|
1891
|
+
@@unique([storyId, designId])
|
|
1880
1892
|
@@index([storyId])
|
|
1881
|
-
@@index([
|
|
1882
|
-
@@map("
|
|
1893
|
+
@@index([designId])
|
|
1894
|
+
@@map("story_design_links")
|
|
1883
1895
|
}
|
|
1884
1896
|
|
|
1885
1897
|
model StoryDocLink {
|
|
@@ -1926,8 +1938,8 @@ model StoryFilterView {
|
|
|
1926
1938
|
description String?
|
|
1927
1939
|
icon String @default("list")
|
|
1928
1940
|
projectId String?
|
|
1929
|
-
filters Json
|
|
1930
|
-
displayOptions Json
|
|
1941
|
+
filters Json @default("{}")
|
|
1942
|
+
displayOptions Json @default("{}")
|
|
1931
1943
|
sortOrder Int @default(0)
|
|
1932
1944
|
createdAt DateTime @default(now())
|
|
1933
1945
|
updatedAt DateTime @updatedAt
|
|
@@ -2015,7 +2027,7 @@ model Plan {
|
|
|
2015
2027
|
maxGuestSeats Int?
|
|
2016
2028
|
maxWorkspaces Int?
|
|
2017
2029
|
aiQuotaMonthly Int?
|
|
2018
|
-
features Json
|
|
2030
|
+
features Json @default("{}")
|
|
2019
2031
|
isPublic Boolean @default(true)
|
|
2020
2032
|
sortOrder Int @default(0)
|
|
2021
2033
|
createdAt DateTime @default(now())
|
|
@@ -2050,9 +2062,9 @@ model Plan {
|
|
|
2050
2062
|
model Subscription {
|
|
2051
2063
|
id String @id @default(cuid())
|
|
2052
2064
|
userId String @unique
|
|
2053
|
-
user User @relation(fields: [userId], references: [id])
|
|
2065
|
+
user User @relation(fields: [userId], references: [id], onDelete: Restrict)
|
|
2054
2066
|
planId String
|
|
2055
|
-
plan Plan @relation(fields: [planId], references: [id])
|
|
2067
|
+
plan Plan @relation(fields: [planId], references: [id], onDelete: Restrict)
|
|
2056
2068
|
status SubscriptionStatus @default(ACTIVE)
|
|
2057
2069
|
|
|
2058
2070
|
/// 席位加购数量(账号级)。实际上限 = plan.maxSeats + addonSeats。
|
|
@@ -2077,6 +2089,7 @@ model Subscription {
|
|
|
2077
2089
|
invoices Invoice[]
|
|
2078
2090
|
|
|
2079
2091
|
@@map("subscriptions")
|
|
2092
|
+
@@index([planId])
|
|
2080
2093
|
}
|
|
2081
2094
|
|
|
2082
2095
|
enum SubscriptionStatus {
|
|
@@ -2092,7 +2105,7 @@ enum SubscriptionStatus {
|
|
|
2092
2105
|
model UsageRecord {
|
|
2093
2106
|
id String @id @default(cuid())
|
|
2094
2107
|
workspaceId String
|
|
2095
|
-
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
|
2108
|
+
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Restrict)
|
|
2096
2109
|
metric UsageMetric
|
|
2097
2110
|
period String
|
|
2098
2111
|
count Int @default(0)
|
|
@@ -2112,6 +2125,20 @@ enum UsageMetric {
|
|
|
2112
2125
|
SEAT
|
|
2113
2126
|
}
|
|
2114
2127
|
|
|
2128
|
+
/// 第三方依赖分类——值集与 kernel 的 DependencyCategory 联合类型对齐
|
|
2129
|
+
/// (packages/kernel/src/contract/modules/dependencies/index.ts,8 值)。
|
|
2130
|
+
/// 新增分类须两处同步:kernel 联合类型 + 本 enum + 迁移 ALTER TYPE ADD VALUE。
|
|
2131
|
+
enum DependencyCategory {
|
|
2132
|
+
framework
|
|
2133
|
+
ui
|
|
2134
|
+
editor
|
|
2135
|
+
ai
|
|
2136
|
+
state
|
|
2137
|
+
auth
|
|
2138
|
+
tool
|
|
2139
|
+
other
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2115
2142
|
/// AI 用量明细(按次扣减 + 成本审计)
|
|
2116
2143
|
model AiUsageLog {
|
|
2117
2144
|
id String @id @default(cuid())
|
|
@@ -2120,7 +2147,7 @@ model AiUsageLog {
|
|
|
2120
2147
|
workspaceId String?
|
|
2121
2148
|
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: Restrict)
|
|
2122
2149
|
userId String
|
|
2123
|
-
user User @relation(fields: [userId], references: [id])
|
|
2150
|
+
user User @relation(fields: [userId], references: [id], onDelete: Restrict)
|
|
2124
2151
|
source String @default("byok")
|
|
2125
2152
|
activity String? // 区分 chat/sandbox/image...(P3 计费维度;null = 既有 byok 语义)
|
|
2126
2153
|
provider String
|
|
@@ -2147,7 +2174,7 @@ model AiUsageLog {
|
|
|
2147
2174
|
model Invoice {
|
|
2148
2175
|
id String @id @default(cuid())
|
|
2149
2176
|
subscriptionId String
|
|
2150
|
-
subscription Subscription @relation(fields: [subscriptionId], references: [id])
|
|
2177
|
+
subscription Subscription @relation(fields: [subscriptionId], references: [id], onDelete: Restrict)
|
|
2151
2178
|
providerInvoiceId String @unique
|
|
2152
2179
|
providerEventId String?
|
|
2153
2180
|
amountDue Int
|
|
@@ -2189,27 +2216,29 @@ model LicenseKey {
|
|
|
2189
2216
|
id String @id @default(cuid())
|
|
2190
2217
|
key String @unique
|
|
2191
2218
|
signature String
|
|
2192
|
-
payload Json
|
|
2219
|
+
payload Json @default("{}")
|
|
2193
2220
|
customerId String
|
|
2194
2221
|
customerName String
|
|
2195
2222
|
customerEmail String
|
|
2196
2223
|
plan String @default("enterprise")
|
|
2197
2224
|
seats Int
|
|
2198
|
-
features Json
|
|
2225
|
+
features Json @default("{}")
|
|
2199
2226
|
issuedAt DateTime @default(now())
|
|
2200
2227
|
expiresAt DateTime?
|
|
2201
2228
|
revokedAt DateTime?
|
|
2202
2229
|
issuedById String?
|
|
2203
|
-
issuedBy User? @relation("LicenseIssuer", fields: [issuedById], references: [id])
|
|
2230
|
+
issuedBy User? @relation("LicenseIssuer", fields: [issuedById], references: [id], onDelete: SetNull)
|
|
2204
2231
|
activations LicenseActivation[]
|
|
2205
2232
|
|
|
2206
2233
|
@@map("license_keys")
|
|
2234
|
+
@@index([issuedById])
|
|
2235
|
+
@@index([customerId])
|
|
2207
2236
|
}
|
|
2208
2237
|
|
|
2209
2238
|
model LicenseActivation {
|
|
2210
2239
|
id String @id @default(cuid())
|
|
2211
2240
|
licenseId String
|
|
2212
|
-
license LicenseKey @relation(fields: [licenseId], references: [id])
|
|
2241
|
+
license LicenseKey @relation(fields: [licenseId], references: [id], onDelete: Cascade)
|
|
2213
2242
|
instanceId String @unique
|
|
2214
2243
|
fingerprint String
|
|
2215
2244
|
activatedAt DateTime @default(now())
|
|
@@ -2217,18 +2246,19 @@ model LicenseActivation {
|
|
|
2217
2246
|
revokedAt DateTime?
|
|
2218
2247
|
|
|
2219
2248
|
@@map("license_activations")
|
|
2249
|
+
@@index([licenseId])
|
|
2220
2250
|
}
|
|
2221
2251
|
|
|
2222
2252
|
// 审计日志
|
|
2223
2253
|
model AuditLog {
|
|
2224
2254
|
id String @id @default(cuid())
|
|
2225
2255
|
workspaceId String?
|
|
2226
|
-
workspace Workspace? @relation(fields: [workspaceId], references: [id])
|
|
2256
|
+
workspace Workspace? @relation(fields: [workspaceId], references: [id], onDelete: SetNull)
|
|
2227
2257
|
userId String?
|
|
2228
2258
|
action String
|
|
2229
2259
|
resourceType String
|
|
2230
2260
|
resourceId String?
|
|
2231
|
-
metadata Json
|
|
2261
|
+
metadata Json @default("{}")
|
|
2232
2262
|
ip String?
|
|
2233
2263
|
userAgent String?
|
|
2234
2264
|
createdAt DateTime @default(now())
|
|
@@ -2243,10 +2273,10 @@ model AuditLog {
|
|
|
2243
2273
|
model SsoProvider {
|
|
2244
2274
|
id String @id @default(cuid())
|
|
2245
2275
|
workspaceId String
|
|
2246
|
-
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
|
2276
|
+
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Restrict)
|
|
2247
2277
|
type String
|
|
2248
2278
|
name String
|
|
2249
|
-
config Json
|
|
2279
|
+
config Json @default("{}")
|
|
2250
2280
|
domain String?
|
|
2251
2281
|
enabled Boolean @default(true)
|
|
2252
2282
|
createdAt DateTime @default(now())
|
|
@@ -2260,24 +2290,25 @@ model SsoProvider {
|
|
|
2260
2290
|
model SsoMapping {
|
|
2261
2291
|
id String @id @default(cuid())
|
|
2262
2292
|
providerId String
|
|
2263
|
-
provider SsoProvider @relation(fields: [providerId], references: [id])
|
|
2293
|
+
provider SsoProvider @relation(fields: [providerId], references: [id], onDelete: Cascade)
|
|
2264
2294
|
externalId String
|
|
2265
2295
|
userId String
|
|
2266
|
-
user User @relation(fields: [userId], references: [id])
|
|
2296
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
2267
2297
|
email String?
|
|
2268
2298
|
createdAt DateTime @default(now())
|
|
2269
2299
|
|
|
2270
2300
|
@@unique([providerId, externalId])
|
|
2271
2301
|
@@map("sso_mappings")
|
|
2302
|
+
@@index([userId])
|
|
2272
2303
|
}
|
|
2273
2304
|
|
|
2274
2305
|
// 自定义角色
|
|
2275
2306
|
model CustomRole {
|
|
2276
2307
|
id String @id @default(cuid())
|
|
2277
2308
|
workspaceId String
|
|
2278
|
-
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
|
2309
|
+
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Restrict)
|
|
2279
2310
|
name String
|
|
2280
|
-
permissions Json
|
|
2311
|
+
permissions Json @default("{}")
|
|
2281
2312
|
isSystem Boolean @default(false)
|
|
2282
2313
|
createdAt DateTime @default(now())
|
|
2283
2314
|
updatedAt DateTime @updatedAt
|
|
@@ -2290,9 +2321,9 @@ model CustomRole {
|
|
|
2290
2321
|
model RoleAssignment {
|
|
2291
2322
|
id String @id @default(cuid())
|
|
2292
2323
|
roleId String
|
|
2293
|
-
role CustomRole @relation(fields: [roleId], references: [id])
|
|
2324
|
+
role CustomRole @relation(fields: [roleId], references: [id], onDelete: Cascade)
|
|
2294
2325
|
userId String
|
|
2295
|
-
user User @relation(fields: [userId], references: [id])
|
|
2326
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
2296
2327
|
createdAt DateTime @default(now())
|
|
2297
2328
|
|
|
2298
2329
|
@@unique([roleId, userId])
|
|
@@ -2400,7 +2431,7 @@ model Notification {
|
|
|
2400
2431
|
// 通知偏好(免打扰时段、分类开关)
|
|
2401
2432
|
model NotificationPreference {
|
|
2402
2433
|
userId String @id
|
|
2403
|
-
categories Json
|
|
2434
|
+
categories Json @default("{}")
|
|
2404
2435
|
emailCategories Json @default("{}")
|
|
2405
2436
|
dndEnabled Boolean @default(false)
|
|
2406
2437
|
dndStart String @default("22:00")
|
|
@@ -2422,14 +2453,16 @@ model Iteration {
|
|
|
2422
2453
|
archived Boolean @default(false)
|
|
2423
2454
|
archivedAt DateTime?
|
|
2424
2455
|
createdById String
|
|
2425
|
-
createdBy User @relation("iterationCreator", fields: [createdById], references: [id])
|
|
2456
|
+
createdBy User @relation("iterationCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
2426
2457
|
createdAt DateTime @default(now())
|
|
2427
2458
|
updatedAt DateTime @updatedAt
|
|
2428
2459
|
stories Story[]
|
|
2460
|
+
testPlans TestPlan[]
|
|
2429
2461
|
|
|
2430
2462
|
@@index([projectId, startDate])
|
|
2431
2463
|
@@index([archived])
|
|
2432
2464
|
@@map("iterations")
|
|
2465
|
+
@@index([createdById])
|
|
2433
2466
|
}
|
|
2434
2467
|
|
|
2435
2468
|
// 迭代自动排期配置(一项目一行)
|
|
@@ -2490,7 +2523,7 @@ model SandboxInstance {
|
|
|
2490
2523
|
model AiStreamChunk {
|
|
2491
2524
|
id BigInt @id @default(autoincrement())
|
|
2492
2525
|
runId String
|
|
2493
|
-
chunk Json
|
|
2526
|
+
chunk Json @default("{}")
|
|
2494
2527
|
createdAt DateTime @default(now())
|
|
2495
2528
|
|
|
2496
2529
|
@@index([runId, id])
|
|
@@ -2499,7 +2532,7 @@ model AiStreamChunk {
|
|
|
2499
2532
|
|
|
2500
2533
|
model DesktopSetting {
|
|
2501
2534
|
key String @id // "aiSourceMode" | "localAgentConfig"
|
|
2502
|
-
value Json
|
|
2535
|
+
value Json @default("{}")
|
|
2503
2536
|
|
|
2504
2537
|
@@map("desktop_settings")
|
|
2505
2538
|
}
|
|
@@ -2554,3 +2587,480 @@ model Blob {
|
|
|
2554
2587
|
@@index([userId])
|
|
2555
2588
|
@@map("blobs")
|
|
2556
2589
|
}
|
|
2590
|
+
|
|
2591
|
+
// ==================== BUG 模块(仅 PG schema,桌面端无 BUG 模块,见规格 ADR-5) ====================
|
|
2592
|
+
|
|
2593
|
+
// BUG 工单主表
|
|
2594
|
+
model Bug {
|
|
2595
|
+
id String @id @default(cuid())
|
|
2596
|
+
sequenceId Int
|
|
2597
|
+
identifier String // "{displayId}-B{seq}"(如 "ABC-B12"),SequenceCounter(scope="bug:{projectId}") 独立发号,前缀加 -B 与需求 identifier 区分
|
|
2598
|
+
projectId String
|
|
2599
|
+
title String
|
|
2600
|
+
description String? @db.Text // TipTap {html, markdown} JSON,与 Story.description 同构
|
|
2601
|
+
reproduceSteps Json? // { steps: [{ order: Int, action: String, expected?: String }], expectedResult?: String, actualResult?: String }
|
|
2602
|
+
state String @default("open") // open|in_progress|fixed|closed|wontfix
|
|
2603
|
+
severity String @default("medium") // critical|high|medium|low
|
|
2604
|
+
source String @default("manual") // manual|sdk_auto|collect|chrome_ext|test_run(test_run:测试执行失败 AI 起草,规格 Q2)
|
|
2605
|
+
pendingConfirm Boolean @default(false) // Q2:AI 起草待确认标记(仅 source=test_run 使用)
|
|
2606
|
+
fingerprint String? // sha256 hex,服务端计算;手动创建为 null
|
|
2607
|
+
env String? // SDK 上报环境:prod|test|dev|自定义
|
|
2608
|
+
url String? @db.Text // 发生页面 URL
|
|
2609
|
+
userAgent String? @db.Text
|
|
2610
|
+
stackSummary String? @db.Text // 归一化前原始堆栈(截断存储,≤64KB;title 截 80 字符、url/ua 截 2KB)
|
|
2611
|
+
totalCount Int @default(1) // 累计上报/命中次数
|
|
2612
|
+
firstOccurAt DateTime @default(now())
|
|
2613
|
+
lastOccurAt DateTime @default(now())
|
|
2614
|
+
assigneeId String?
|
|
2615
|
+
createdById String
|
|
2616
|
+
updatedById String?
|
|
2617
|
+
storyId String? // 关联需求(单值 FK,可空)
|
|
2618
|
+
repoHints String? @db.Text // AI 复现用仓库线索(如 "github.com/org/repo,登录页 src/views/Login.tsx")
|
|
2619
|
+
archived Boolean @default(false)
|
|
2620
|
+
archivedAt DateTime?
|
|
2621
|
+
createdAt DateTime @default(now())
|
|
2622
|
+
updatedAt DateTime @updatedAt
|
|
2623
|
+
|
|
2624
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Restrict)
|
|
2625
|
+
story Story? @relation(fields: [storyId], references: [id], onDelete: SetNull)
|
|
2626
|
+
assignee User? @relation("bugAssignee", fields: [assigneeId], references: [id], onDelete: SetNull)
|
|
2627
|
+
createdBy User @relation("bugCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
2628
|
+
updatedBy User? @relation("bugEditor", fields: [updatedById], references: [id], onDelete: SetNull)
|
|
2629
|
+
|
|
2630
|
+
events BugEvent[]
|
|
2631
|
+
activities BugActivity[]
|
|
2632
|
+
comments BugComment[]
|
|
2633
|
+
fixRuns BugFixRun[]
|
|
2634
|
+
reproRuns BugReproRun[]
|
|
2635
|
+
labels BugLabel[]
|
|
2636
|
+
runCases TestRunCase[]
|
|
2637
|
+
|
|
2638
|
+
@@unique([projectId, identifier])
|
|
2639
|
+
@@unique([projectId, fingerprint]) // 可空字段 unique:多个 null 不冲突,手动 BUG 互不影响
|
|
2640
|
+
@@index([projectId, sequenceId])
|
|
2641
|
+
@@index([state])
|
|
2642
|
+
@@index([archived, state, createdAt])
|
|
2643
|
+
@@index([assigneeId])
|
|
2644
|
+
@@index([createdById])
|
|
2645
|
+
@@index([storyId])
|
|
2646
|
+
@@index([projectId, lastOccurAt])
|
|
2647
|
+
@@map("bugs")
|
|
2648
|
+
@@index([updatedById])
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
// 事件明细(采样存储:同指纹时间窗口内最多存 1 条快照)
|
|
2652
|
+
model BugEvent {
|
|
2653
|
+
id String @id @default(cuid())
|
|
2654
|
+
bugId String
|
|
2655
|
+
bug Bug @relation(fields: [bugId], references: [id], onDelete: Cascade)
|
|
2656
|
+
rawPayload Json // 精简后的原始上报报文(堆栈/面包屑/浏览器/自定义 extra);受请求级 256KB 上限约束,落库前再按事件截断至 64KB
|
|
2657
|
+
occurTime DateTime @default(now())
|
|
2658
|
+
userAgent String? @db.Text
|
|
2659
|
+
|
|
2660
|
+
@@index([bugId, occurTime])
|
|
2661
|
+
@@map("bug_events")
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
// 活动流水(照 StoryActivity 模式;两处有意偏离:userId 可空 + actorType/agentName,SDK 与 AI agent 写入的活动无登录用户)
|
|
2665
|
+
model BugActivity {
|
|
2666
|
+
id String @id @default(cuid())
|
|
2667
|
+
bugId String
|
|
2668
|
+
bug Bug @relation(fields: [bugId], references: [id], onDelete: Cascade)
|
|
2669
|
+
userId String? // 手动操作时必填;sdk/agent 产生时为 null
|
|
2670
|
+
user User? @relation("bugActivityUser", fields: [userId], references: [id], onDelete: SetNull)
|
|
2671
|
+
actorType String @default("user") // user|sdk|agent|system
|
|
2672
|
+
agentName String? // actorType=agent 时标识(如 "opencode")
|
|
2673
|
+
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
|
|
2674
|
+
field String?
|
|
2675
|
+
oldValue String? @db.Text
|
|
2676
|
+
newValue String? @db.Text
|
|
2677
|
+
isAI Boolean @default(false)
|
|
2678
|
+
metadata Json?
|
|
2679
|
+
createdAt DateTime @default(now())
|
|
2680
|
+
|
|
2681
|
+
@@index([bugId, createdAt])
|
|
2682
|
+
@@map("bug_activities")
|
|
2683
|
+
@@index([userId])
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
// 评论(照 StoryComment:parentId 自关联回复树)
|
|
2687
|
+
model BugComment {
|
|
2688
|
+
id String @id @default(cuid())
|
|
2689
|
+
bugId String
|
|
2690
|
+
bug Bug @relation(fields: [bugId], references: [id], onDelete: Cascade)
|
|
2691
|
+
userId String
|
|
2692
|
+
user User @relation("bugCommentUser", fields: [userId], references: [id], onDelete: Cascade)
|
|
2693
|
+
parentId String?
|
|
2694
|
+
parent BugComment? @relation("BugCommentReply", fields: [parentId], references: [id], onDelete: Cascade)
|
|
2695
|
+
replies BugComment[] @relation("BugCommentReply")
|
|
2696
|
+
content String @db.Text
|
|
2697
|
+
createdAt DateTime @default(now())
|
|
2698
|
+
updatedAt DateTime @updatedAt
|
|
2699
|
+
|
|
2700
|
+
@@index([bugId, createdAt])
|
|
2701
|
+
@@index([parentId])
|
|
2702
|
+
@@map("bug_comments")
|
|
2703
|
+
@@index([userId])
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
// 统一项目接入凭证(一张表 + scope 区分类别,替代三张独立 token 表)
|
|
2707
|
+
model ProjectAccessToken {
|
|
2708
|
+
id String @id @default(cuid())
|
|
2709
|
+
projectId String
|
|
2710
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2711
|
+
name String // 展示名:"生产环境" / "公开收集页" / "opencode"
|
|
2712
|
+
scope String // bug.report(SDK/扩展上报) | bug.collect(收集页) | bug.mcp(MCP) | test.exec(AI 执行)
|
|
2713
|
+
tokenHash String @unique // sha256(明文),明文不落库
|
|
2714
|
+
tokenPrefix String // 明文前 8 字符("abk_9x8z"),列表识别用
|
|
2715
|
+
config Json? // scope=bug.collect: { title?, description?, severityVisible?, screenshotEnabled? }
|
|
2716
|
+
lastUsedAt DateTime?
|
|
2717
|
+
revokedAt DateTime? // 非空即吊销
|
|
2718
|
+
createdById String
|
|
2719
|
+
// 产品决策(审查修复):Restrict——token 是项目级活凭证(bug.report SDK / test.exec CI),
|
|
2720
|
+
// 非创建者个人内容;删创建者静默销毁凭证会让集成端 401。createdById required 无法 SetNull。
|
|
2721
|
+
createdBy User @relation("tokenCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
2722
|
+
createdAt DateTime @default(now())
|
|
2723
|
+
|
|
2724
|
+
@@index([projectId, scope])
|
|
2725
|
+
@@map("project_access_tokens")
|
|
2726
|
+
@@index([createdById])
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2729
|
+
// AI 修复状态机:pending →(claim_fix) claimed →(report_progress 首次) in_progress →(report_result) completed|failed;用户可取消 → cancelled
|
|
2730
|
+
model BugFixRun {
|
|
2731
|
+
id String @id @default(cuid())
|
|
2732
|
+
bugId String
|
|
2733
|
+
bug Bug @relation(fields: [bugId], references: [id], onDelete: Cascade)
|
|
2734
|
+
status String @default("pending") // pending|claimed|in_progress|completed|failed|cancelled
|
|
2735
|
+
triggerType String // manual|auto
|
|
2736
|
+
agentName String? // claim_fix 时由 MCP 客户端传入(tool 入参)
|
|
2737
|
+
claimedAt DateTime?
|
|
2738
|
+
completedAt DateTime?
|
|
2739
|
+
summary Json? // { result: "fixed"|"failed"|"cannot_reproduce", summaryText, commitUrl?, prUrl?, changedFiles: String[] }
|
|
2740
|
+
createdAt DateTime @default(now())
|
|
2741
|
+
|
|
2742
|
+
@@index([bugId, createdAt])
|
|
2743
|
+
@@index([status, createdAt])
|
|
2744
|
+
@@map("bug_fix_runs")
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2747
|
+
// AI 复现(mode=static;dynamic 为 P2 预留)
|
|
2748
|
+
model BugReproRun {
|
|
2749
|
+
id String @id @default(cuid())
|
|
2750
|
+
bugId String
|
|
2751
|
+
bug Bug @relation(fields: [bugId], references: [id], onDelete: Cascade)
|
|
2752
|
+
mode String @default("static") // static|dynamic(MVP 仅 static)
|
|
2753
|
+
status String @default("running") // running|completed|failed
|
|
2754
|
+
report Json? // 结构化报告(规格 §12)
|
|
2755
|
+
error String? @db.Text
|
|
2756
|
+
createdById String
|
|
2757
|
+
createdBy User @relation("bugReproCreator", fields: [createdById], references: [id], onDelete: Cascade)
|
|
2758
|
+
createdAt DateTime @default(now())
|
|
2759
|
+
|
|
2760
|
+
@@index([bugId, createdAt])
|
|
2761
|
+
@@map("bug_repro_runs")
|
|
2762
|
+
@@index([createdById])
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
// 出站通知(HMAC-SHA256 签名;MVP 同步 fire-and-forget + 5s 超时,不建投递表)
|
|
2766
|
+
model ProjectWebhook {
|
|
2767
|
+
id String @id @default(cuid())
|
|
2768
|
+
projectId String
|
|
2769
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2770
|
+
url String @db.Text
|
|
2771
|
+
secret String @db.Text // HMAC-SHA256 签名密钥
|
|
2772
|
+
events Json @default("[]") // ["bug.created","fix.requested","fix.completed"]
|
|
2773
|
+
enabled Boolean @default(true)
|
|
2774
|
+
createdAt DateTime @default(now())
|
|
2775
|
+
|
|
2776
|
+
@@index([projectId])
|
|
2777
|
+
@@map("project_webhooks")
|
|
2778
|
+
}
|
|
2779
|
+
|
|
2780
|
+
// 项目级 BUG 配置(PG only 独立表守 ADR-5 边界;projectId 为主键一项目一行,首次访问惰性 upsert 建行)
|
|
2781
|
+
model BugProjectSettings {
|
|
2782
|
+
projectId String @id
|
|
2783
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2784
|
+
autoReportEnabled Boolean @default(true) // SDK 上报总开关(关:上报接口对该项目返回 ok 但丢弃)
|
|
2785
|
+
sampleRate Float @default(1) // 服务端二次采样(0-1,与 SDK 端采样独立叠加)
|
|
2786
|
+
reopenOnDuplicate Boolean @default(true) // fixed/closed 收到重复上报自动转 open
|
|
2787
|
+
autoFixEnabled Boolean @default(false) // 新指纹 BUG 自动入队 AI 修复
|
|
2788
|
+
autoSubmitTestBugs Boolean @default(false) // true=跳过人工确认闸门(测试失败 AI 起草 bug 直接转正,规格 Q2)
|
|
2789
|
+
updatedAt DateTime @updatedAt
|
|
2790
|
+
|
|
2791
|
+
@@map("bug_project_settings")
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2794
|
+
// BUG ↔ 标签 join 表(照 StoryLabel,标签池与 Story 共用)
|
|
2795
|
+
model BugLabel {
|
|
2796
|
+
bugId String
|
|
2797
|
+
labelId String
|
|
2798
|
+
bug Bug @relation(fields: [bugId], references: [id], onDelete: Cascade)
|
|
2799
|
+
label Label @relation(fields: [labelId], references: [id], onDelete: Cascade)
|
|
2800
|
+
|
|
2801
|
+
@@id([bugId, labelId])
|
|
2802
|
+
@@index([bugId])
|
|
2803
|
+
@@index([labelId])
|
|
2804
|
+
@@map("bug_labels")
|
|
2805
|
+
}
|
|
2806
|
+
|
|
2807
|
+
// BUG 列表过滤器视图(per-user 保存,照 StoryFilterView 字段结构;无 bugId 关联)
|
|
2808
|
+
model BugFilterView {
|
|
2809
|
+
id String @id @default(cuid())
|
|
2810
|
+
userId String
|
|
2811
|
+
name String
|
|
2812
|
+
projectId String?
|
|
2813
|
+
filters Json @default("{}")
|
|
2814
|
+
displayOptions Json @default("{}")
|
|
2815
|
+
createdAt DateTime @default(now())
|
|
2816
|
+
updatedAt DateTime @updatedAt
|
|
2817
|
+
|
|
2818
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
2819
|
+
|
|
2820
|
+
@@index([userId])
|
|
2821
|
+
@@map("bug_filter_views")
|
|
2822
|
+
}
|
|
2823
|
+
|
|
2824
|
+
// ==================== 测试用例模块(仅 PG schema,D7:桌面端不同步,规格 2026-10-04-testcase-module §3) ====================
|
|
2825
|
+
|
|
2826
|
+
// 用例主表(identifier 由 SequenceCounter(scope="testcase:{projectId}") 发号)
|
|
2827
|
+
model TestCase {
|
|
2828
|
+
id String @id @default(cuid())
|
|
2829
|
+
sequenceId Int
|
|
2830
|
+
identifier String // "{displayId}-TC{seq}",SequenceCounter(scope="testcase:{projectId}")
|
|
2831
|
+
projectId String
|
|
2832
|
+
folderId String?
|
|
2833
|
+
storyId String?
|
|
2834
|
+
title String
|
|
2835
|
+
precondition String? @db.Text
|
|
2836
|
+
steps Json @default("{\"steps\":[]}") // { steps: [{ order, action, expected? }] }——与 Bug.reproduceSteps 步骤结构同构
|
|
2837
|
+
type String @default("functional") // functional|boundary|exception|performance|security|compatibility
|
|
2838
|
+
priority String @default("p1") // p0|p1|p2|p3
|
|
2839
|
+
state String @default("draft") // draft|in_review|approved|deprecated
|
|
2840
|
+
version Int @default(1) // 每次内容编辑 +1
|
|
2841
|
+
automation String @default("none") // none|unit|e2e|both
|
|
2842
|
+
aiGenerated Boolean @default(false)
|
|
2843
|
+
generationId String?
|
|
2844
|
+
assigneeId String?
|
|
2845
|
+
createdById String
|
|
2846
|
+
archived Boolean @default(false)
|
|
2847
|
+
archivedAt DateTime?
|
|
2848
|
+
createdAt DateTime @default(now())
|
|
2849
|
+
updatedAt DateTime @updatedAt
|
|
2850
|
+
|
|
2851
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Restrict)
|
|
2852
|
+
folder TestCaseFolder? @relation(fields: [folderId], references: [id], onDelete: SetNull)
|
|
2853
|
+
story Story? @relation(fields: [storyId], references: [id], onDelete: SetNull)
|
|
2854
|
+
assignee User? @relation("testCaseAssignee", fields: [assigneeId], references: [id], onDelete: SetNull)
|
|
2855
|
+
createdBy User @relation("testCaseCreator", fields: [createdById], references: [id], onDelete: Restrict)
|
|
2856
|
+
artifacts TestAutomationArtifact[]
|
|
2857
|
+
runCases TestRunCase[]
|
|
2858
|
+
planCases TestPlanCase[]
|
|
2859
|
+
|
|
2860
|
+
@@unique([projectId, identifier])
|
|
2861
|
+
@@index([projectId, folderId])
|
|
2862
|
+
@@index([projectId, state])
|
|
2863
|
+
@@index([storyId])
|
|
2864
|
+
@@map("test_cases")
|
|
2865
|
+
@@index([assigneeId])
|
|
2866
|
+
@@index([createdById])
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
// 模块树
|
|
2870
|
+
model TestCaseFolder {
|
|
2871
|
+
id String @id @default(cuid())
|
|
2872
|
+
projectId String
|
|
2873
|
+
parentId String?
|
|
2874
|
+
name String
|
|
2875
|
+
position Int @default(0)
|
|
2876
|
+
|
|
2877
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2878
|
+
parent TestCaseFolder? @relation("FolderTree", fields: [parentId], references: [id], onDelete: Cascade)
|
|
2879
|
+
children TestCaseFolder[] @relation("FolderTree")
|
|
2880
|
+
cases TestCase[]
|
|
2881
|
+
|
|
2882
|
+
@@index([projectId, parentId])
|
|
2883
|
+
@@map("test_case_folders")
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2886
|
+
// 保存的筛选视图(结构对齐 StoryFilterView;projectId 仅普通列,无项目 FK)
|
|
2887
|
+
model TestCaseFilterView {
|
|
2888
|
+
id String @id @default(cuid())
|
|
2889
|
+
userId String
|
|
2890
|
+
name String
|
|
2891
|
+
description String?
|
|
2892
|
+
icon String @default("list")
|
|
2893
|
+
projectId String?
|
|
2894
|
+
filters Json @default("{}") // { folderId?, type?, priority?, state?, automation?, assigneeId?, label?, storyId?, searchText? }
|
|
2895
|
+
displayOptions Json @default("{}") // { groupBy: "folder"|"state"|"priority"|"none", view: "list"|"table", density? }
|
|
2896
|
+
sortOrder Int @default(0)
|
|
2897
|
+
createdAt DateTime @default(now())
|
|
2898
|
+
updatedAt DateTime @updatedAt
|
|
2899
|
+
|
|
2900
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
2901
|
+
|
|
2902
|
+
@@index([userId, projectId])
|
|
2903
|
+
@@map("test_case_filter_views")
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
// AI 生成批次(从 Story 结构化生成草稿,人工评审采纳)
|
|
2907
|
+
model TestGenerationRun {
|
|
2908
|
+
id String @id @default(cuid())
|
|
2909
|
+
projectId String
|
|
2910
|
+
storyId String
|
|
2911
|
+
status String @default("running") // running|completed|failed
|
|
2912
|
+
error String? @db.Text
|
|
2913
|
+
input Json? // { storySnapshot: {name, descriptionText}, acceptanceCriteria: string[], kbContext: {docId, excerpt}[] }
|
|
2914
|
+
output Json? // AI 原始结构化产物(评审对照)
|
|
2915
|
+
draftCount Int @default(0)
|
|
2916
|
+
adoptedCount Int @default(0)
|
|
2917
|
+
createdById String
|
|
2918
|
+
createdAt DateTime @default(now())
|
|
2919
|
+
completedAt DateTime?
|
|
2920
|
+
|
|
2921
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2922
|
+
story Story @relation(fields: [storyId], references: [id], onDelete: Cascade)
|
|
2923
|
+
createdBy User @relation("testGenCreator", fields: [createdById], references: [id], onDelete: Cascade)
|
|
2924
|
+
|
|
2925
|
+
@@index([projectId, createdAt])
|
|
2926
|
+
@@index([storyId])
|
|
2927
|
+
@@map("test_generation_runs")
|
|
2928
|
+
@@index([createdById])
|
|
2929
|
+
}
|
|
2930
|
+
|
|
2931
|
+
// 测试计划
|
|
2932
|
+
model TestPlan {
|
|
2933
|
+
id String @id @default(cuid())
|
|
2934
|
+
projectId String
|
|
2935
|
+
iterationId String?
|
|
2936
|
+
name String
|
|
2937
|
+
description String? @db.Text
|
|
2938
|
+
state String @default("active") // active|closed
|
|
2939
|
+
createdById String
|
|
2940
|
+
createdAt DateTime @default(now())
|
|
2941
|
+
updatedAt DateTime @updatedAt
|
|
2942
|
+
|
|
2943
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2944
|
+
iteration Iteration? @relation(fields: [iterationId], references: [id], onDelete: SetNull)
|
|
2945
|
+
runs TestRun[]
|
|
2946
|
+
planCases TestPlanCase[]
|
|
2947
|
+
@@index([projectId, state])
|
|
2948
|
+
@@map("test_plans")
|
|
2949
|
+
@@index([iterationId])
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
// 计划-用例圈选关联(TestPlanCase):@@unique([planId, caseId]) 保证重复加入不产生重复行
|
|
2953
|
+
//(addCasesToPlan 幂等的 DB 层防线);用例/计划删除时级联清理。
|
|
2954
|
+
model TestPlanCase {
|
|
2955
|
+
id String @id @default(cuid())
|
|
2956
|
+
planId String
|
|
2957
|
+
caseId String
|
|
2958
|
+
createdAt DateTime @default(now())
|
|
2959
|
+
|
|
2960
|
+
plan TestPlan @relation(fields: [planId], references: [id], onDelete: Cascade)
|
|
2961
|
+
case TestCase @relation(fields: [caseId], references: [id], onDelete: Cascade)
|
|
2962
|
+
|
|
2963
|
+
@@unique([planId, caseId])
|
|
2964
|
+
@@index([caseId])
|
|
2965
|
+
@@map("test_plan_cases")
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
// 执行批次
|
|
2969
|
+
model TestRun {
|
|
2970
|
+
id String @id @default(cuid())
|
|
2971
|
+
projectId String
|
|
2972
|
+
planId String?
|
|
2973
|
+
name String
|
|
2974
|
+
trigger String @default("manual") // manual|ai|schedule|webhook
|
|
2975
|
+
executorType String @default("human") // human|ai_agent|automation_code|mixed
|
|
2976
|
+
targetEnv String? // 环境标识/URL
|
|
2977
|
+
status String @default("running") // running|completed|aborted
|
|
2978
|
+
summary Json? // { total, passed, failed, blocked, skipped, retest, passRate, durationMs }
|
|
2979
|
+
startedAt DateTime?
|
|
2980
|
+
completedAt DateTime?
|
|
2981
|
+
createdById String
|
|
2982
|
+
createdAt DateTime @default(now())
|
|
2983
|
+
|
|
2984
|
+
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
2985
|
+
plan TestPlan? @relation(fields: [planId], references: [id], onDelete: SetNull)
|
|
2986
|
+
cases TestRunCase[]
|
|
2987
|
+
@@index([projectId, createdAt])
|
|
2988
|
+
@@index([planId])
|
|
2989
|
+
@@map("test_runs")
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
// 批次内用例执行记录(caseSnapshot 快照锁版本)
|
|
2993
|
+
model TestRunCase {
|
|
2994
|
+
id String @id @default(cuid())
|
|
2995
|
+
runId String
|
|
2996
|
+
caseId String
|
|
2997
|
+
caseVersion Int
|
|
2998
|
+
caseSnapshot Json @default("{}") // { title, precondition, steps, priority, type }——执行时快照
|
|
2999
|
+
status String @default("untested") // untested|passed|failed|blocked|skipped|retest
|
|
3000
|
+
stepResults Json? // [{ order, status: pass|fail|blocked|skip, actual?, evidenceBlobIds?: string[] }]
|
|
3001
|
+
actualResult String? @db.Text
|
|
3002
|
+
bugId String?
|
|
3003
|
+
execRunId String?
|
|
3004
|
+
flaky Boolean @default(false)
|
|
3005
|
+
fingerprint String?
|
|
3006
|
+
startedAt DateTime?
|
|
3007
|
+
finishedAt DateTime?
|
|
3008
|
+
durationMs Int?
|
|
3009
|
+
executedById String?
|
|
3010
|
+
|
|
3011
|
+
run TestRun @relation(fields: [runId], references: [id], onDelete: Cascade)
|
|
3012
|
+
case TestCase @relation(fields: [caseId], references: [id], onDelete: Cascade)
|
|
3013
|
+
bug Bug? @relation(fields: [bugId], references: [id], onDelete: SetNull)
|
|
3014
|
+
execRun TestExecRun? @relation("testExecCurrent", fields: [execRunId], references: [id], onDelete: SetNull)
|
|
3015
|
+
execRuns TestExecRun[] @relation("testExecHistory")
|
|
3016
|
+
executedBy User? @relation("testRunCaseExecutor", fields: [executedById], references: [id], onDelete: SetNull)
|
|
3017
|
+
|
|
3018
|
+
@@unique([runId, caseId])
|
|
3019
|
+
@@index([caseId])
|
|
3020
|
+
@@index([bugId])
|
|
3021
|
+
@@map("test_run_cases")
|
|
3022
|
+
@@index([execRunId])
|
|
3023
|
+
@@index([executedById])
|
|
3024
|
+
}
|
|
3025
|
+
|
|
3026
|
+
// AI 执行运行记录(MCP 认领-回报协议)
|
|
3027
|
+
model TestExecRun {
|
|
3028
|
+
id String @id @default(cuid())
|
|
3029
|
+
runCaseId String
|
|
3030
|
+
mode String @default("browser") // browser|api
|
|
3031
|
+
status String @default("claimed") // claimed|running|completed|failed|cancelled|timeout_reclaimed
|
|
3032
|
+
agentName String?
|
|
3033
|
+
report Json? // { perStep: [{ order, action, observed, verdict: pass|fail|uncertain, screenshotBlobId? }], consoleLog?: string[], networkLog?: string[], finalVerdict, confidence }
|
|
3034
|
+
error String? @db.Text
|
|
3035
|
+
claimedAt DateTime? @default(now())
|
|
3036
|
+
completedAt DateTime?
|
|
3037
|
+
createdAt DateTime @default(now())
|
|
3038
|
+
|
|
3039
|
+
runCase TestRunCase @relation("testExecHistory", fields: [runCaseId], references: [id], onDelete: Cascade)
|
|
3040
|
+
currentRunCases TestRunCase[] @relation("testExecCurrent")
|
|
3041
|
+
@@index([status, claimedAt])
|
|
3042
|
+
@@map("test_exec_runs")
|
|
3043
|
+
@@index([runCaseId])
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
// AI 生成的自动化代码(E2E/单测;caseVersion 超过 case.version 即 stale)
|
|
3047
|
+
model TestAutomationArtifact {
|
|
3048
|
+
id String @id @default(cuid())
|
|
3049
|
+
caseId String
|
|
3050
|
+
caseVersion Int // 生成时的用例版本——case.version 超过它即 stale(UI 标「过期待重生成」,复跑排除)
|
|
3051
|
+
kind String // unit|e2e
|
|
3052
|
+
status String @default("draft") // draft|verified|adopted|rejected
|
|
3053
|
+
language String @default("typescript")
|
|
3054
|
+
code String @db.Text
|
|
3055
|
+
targetPath String?
|
|
3056
|
+
verifyRun Json? // { passed, failed, skipped, coverage?, logBlobId?, attempts, lastError? }
|
|
3057
|
+
createdById String
|
|
3058
|
+
createdAt DateTime @default(now())
|
|
3059
|
+
adoptedAt DateTime?
|
|
3060
|
+
|
|
3061
|
+
case TestCase @relation(fields: [caseId], references: [id], onDelete: Cascade)
|
|
3062
|
+
createdBy User @relation("testArtifactCreator", fields: [createdById], references: [id], onDelete: Cascade)
|
|
3063
|
+
@@index([caseId, kind])
|
|
3064
|
+
@@map("test_automation_artifacts")
|
|
3065
|
+
@@index([createdById])
|
|
3066
|
+
}
|