forked from InvolutionHell/involutionhell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.prisma
More file actions
141 lines (114 loc) · 3.59 KB
/
schema.prisma
File metadata and controls
141 lines (114 loc) · 3.59 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
generator client {
provider = "prisma-client"
output = "../generated/prisma"
}
datasource db {
provider = "postgresql"
}
model Account {
id Int @id @default(autoincrement())
userId Int
type String @db.VarChar(255)
provider String @db.VarChar(255)
providerAccountId String @db.VarChar(255)
refresh_token String?
access_token String?
expires_at BigInt?
id_token String?
scope String?
session_state String?
token_type String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@index([userId])
@@map("accounts")
}
model doc_contributors {
doc_id String
github_id BigInt
contributions Int @default(1)
last_contributed_at DateTime @default(now()) @db.Timestamptz(6)
created_at DateTime @default(now()) @db.Timestamptz(6)
updated_at DateTime @updatedAt @db.Timestamptz(6)
docs docs @relation(fields: [doc_id], references: [id], onDelete: Cascade)
@@id([doc_id, github_id])
@@index([doc_id])
@@index([github_id]) // 便于反查某用户在哪些文档有贡献
}
model docs {
id String @id
path_current String?
title String?
created_at DateTime @default(now()) @db.Timestamptz(6)
updated_at DateTime @updatedAt @db.Timestamptz(6)
doc_contributors doc_contributors[]
/// 作为聚合缓存使用:{"github_id": contributions}
/// 兼容性最好用 dbgenerated 设置 PG 端默认 '{}'
contributor_stats Json? @default(dbgenerated("'{}'::jsonb")) @db.JsonB
doc_paths doc_paths[]
}
model Session {
id Int @id @default(autoincrement())
userId Int
expires DateTime @db.Timestamptz(6)
sessionToken String @unique @db.VarChar(255)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
@@map("sessions")
}
model User {
id Int @id @default(autoincrement())
name String? @db.VarChar(255)
email String? @unique @db.VarChar(255)
emailVerified DateTime? @db.Timestamptz(6)
image String?
accounts Account[]
sessions Session[]
chats Chat[]
analyticsEvents AnalyticsEvent[]
@@map("users")
}
model VerificationToken {
identifier String
expires DateTime @db.Timestamptz(6)
token String
@@id([identifier, token])
@@map("verification_token")
}
model doc_paths {
doc_id String
path String
created_at DateTime @default(now()) @db.Timestamptz(6)
updated_at DateTime @updatedAt @db.Timestamptz(6)
docs docs @relation(fields: [doc_id], references: [id], onDelete: Cascade)
@@id([doc_id, path])
@@index([path])
}
model Chat {
id String @id @default(cuid())
userId Int?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
messages Message[]
user User? @relation(fields: [userId], references: [id])
@@index([userId])
}
model Message {
id String @id @default(cuid())
chatId String
role String
content String
createdAt DateTime @default(now())
chat Chat @relation(fields: [chatId], references: [id], onDelete: Cascade)
@@index([chatId])
}
model AnalyticsEvent {
id String @id @default(cuid())
userId Int?
eventType String
eventData Json?
createdAt DateTime @default(now())
user User? @relation(fields: [userId], references: [id])
@@index([eventType])
@@index([userId])
}