-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.prisma
More file actions
71 lines (51 loc) · 1.46 KB
/
schema.prisma
File metadata and controls
71 lines (51 loc) · 1.46 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
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model Settings {
key String @id @unique
value String
}
model User {
id Int @id @default(autoincrement())
tg_chatid Int? @unique
name String
username String @unique // user can not have @username
is_admin Boolean
forms FilledForm[] // forms filled
messages ArchivedMessage[]
acceptances FormAcceptance[]
@@index([tg_chatid])
}
model FilledForm {
id Int @id @default(autoincrement())
timestamp DateTime
user_chat_id Int
user User @relation(fields: [user_chat_id], references: [tg_chatid])
answers String // JSON
acceptances FormAcceptance[]
ArchivedMessage ArchivedMessage[]
}
model FormAcceptance {
id Int @id @default(autoincrement())
form_id Int
form FilledForm @relation(fields: [form_id], references: [id])
accepted_by_tg_chatid Int // is accepted by admins
accepted_by User @relation(fields: [accepted_by_tg_chatid], references: [tg_chatid])
timestamp DateTime
}
model ArchivedMessage {
id Int @id @default(autoincrement())
kind Int // enum PurposeOfMessage
user User @relation(fields: [tg_chatid], references: [tg_chatid])
form_id Int?
form FilledForm? @relation(fields: [form_id], references: [id])
tg_chatid Int
msg_id Int
reply_to_user_chatid Int?
reply_to_msg_id Int?
@@index([tg_chatid, msg_id])
}