-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathschema.prisma
More file actions
218 lines (170 loc) · 6.43 KB
/
Copy pathschema.prisma
File metadata and controls
218 lines (170 loc) · 6.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
}
// ==========================================
// 1. Auth.js (NextAuth) 鏍囧噯璐︽埛浣撶郴涓庢墿锟?
// ==========================================
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
role String @default("USER")
githubPat String?
githubLogin String?
accounts Account[]
sessions Session[]
revisions Revision[] @relation("RevisionAuthor")
reviews Revision[] @relation("RevisionReviewer")
glossaryRevisions GlossaryRevision[] @relation("GlossaryRevisionAuthor")
features Feature[] @relation("FeatureAuthor")
assignedFeatures Feature[] @relation("FeatureAssignee")
featureComments FeatureComment[] @relation("CommentAuthor")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
}
model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model Revision {
id String @id @default(cuid())
title String
content String
coverImage String?
status String @default("DRAFT") // DRAFT, SYNC_CONFLICT, IN_REVIEW
githubPrUrl String?
githubPrNum Int?
prBranchName String?
filePath String?
baseMainSha String?
syncedMainSha String?
conflictContent String?
submittedAt DateTime?
authorId String
author User @relation("RevisionAuthor", fields: [authorId], references: [id])
reviewerId String?
reviewer User? @relation("RevisionReviewer", fields: [reviewerId], references: [id], onDelete: SetNull)
rebaseState Json?
conflictMode String?
// Draft asset lifecycle relation
draftAssets DraftAsset[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
// ==========================================
// 4. Glossary Revision (beta)
// ==========================================
model GlossaryRevision {
id String @id @default(cuid())
authorId String
author User @relation("GlossaryRevisionAuthor", fields: [authorId], references: [id], onDelete: Cascade)
title String?
status String @default("DRAFT") // DRAFT | PENDING | SUBMITTED
operations Json // array of { kind, slug, before?, after? }
baseSubmoduleSha String?
branchName String?
githubPrUrl String?
githubPrNum Int?
submittedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([authorId, status])
@@index([updatedAt])
}
// ==========================================
// 5. Feature Report
// ==========================================
model Feature {
id String @id @default(cuid())
title String
content String
explanation String?
tags String[]
status String @default("PENDING") // PENDING, IN_PROGRESS, RESOLVED
authorId String
author User @relation("FeatureAuthor", fields: [authorId], references: [id])
assigneeId String?
assignee User? @relation("FeatureAssignee", fields: [assigneeId], references: [id])
comments FeatureComment[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model FeatureComment {
id String @id @default(cuid())
content String
featureId String
feature Feature @relation(fields: [featureId], references: [id], onDelete: Cascade)
authorId String
author User @relation("CommentAuthor", fields: [authorId], references: [id])
createdAt DateTime @default(now())
}
// ==========================================
// 6. Draft Asset Lifecycle
// ==========================================
model DraftAsset {
id String @id @default(cuid())
// Link to revision (draft owner)
revisionId String
revision Revision @relation(fields: [revisionId], references: [id], onDelete: Cascade)
// Storage metadata
storagePath String // Supabase object path (e.g., "draft-temp/rev-{id}/filename.png")
mimeType String // e.g., "image/png"
fileSize Int // bytes
filename String // original filename for reference
contentHash String? // SHA256 or similar for dedup/integrity
// Lifecycle status: uploaded, referenced, orphaned, migrated-to-repo, PR-merged, PR-closed, deleted, cleanup-failed
status String @default("uploaded") // tracks asset state through lifecycle
// PR linkage (populated after submit)
githubPrNum Int? // PR number if this asset was migrated during submit
// Migrated repo path (populated after successful migration)
migratedRepoPath String? // e.g., "chapters/chapter-name/img/filename-hash.png"
// Cleanup tracking
cleanupAttempts Int @default(0)
cleanupFailedAt DateTime?
cleanupFailureReason String?
// Timestamps
uploadedAt DateTime @default(now())
migratedAt DateTime?
deletedAt DateTime?
updatedAt DateTime @updatedAt
// Indexes for efficient reconciliation queries
@@unique([revisionId, storagePath])
@@index([status])
@@index([githubPrNum])
@@index([revisionId, status])
}
// ==========================================
// 7. Conflict Resolution Cache
// ==========================================
model ConflictResolution {
id String @id @default(cuid())
conflictHash String @unique
filePath String
resolution String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}