forked from techmc-wiki/gtmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.prisma
More file actions
176 lines (140 loc) · 5.23 KB
/
Copy pathschema.prisma
File metadata and controls
176 lines (140 loc) · 5.23 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
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")
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. 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])
}
// ==========================================
// 6. Conflict Resolution Cache
// ==========================================
model ConflictResolution {
id String @id @default(cuid())
conflictHash String @unique
filePath String
resolution String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}