This repository has been archived by the owner on Nov 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.prisma
88 lines (69 loc) · 1.85 KB
/
schema.prisma
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
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL")
directUrl = env("POSTGRES_URL_NON_POOLING")
}
model User {
id String @id
receipts Receipt[]
}
model Item {
code String @id
name String
picture String
issuedAt DateTime @default(now()) @map("issued_at")
displays Display[]
}
model Event {
code String @id
name String
date DateTime
// passed to new Function()
// must be a JavaScript pure function
// (state: { [K in ItemCode]: { count: number, dedication?: boolean } }) => number
calculator String @default("return 0") @db.Text
displays Display[]
receipts Receipt[]
}
model Display {
event Event @relation(fields: [eventcode], references: [code])
eventcode String
item Item @relation(fields: [itemcode], references: [code])
itemcode String
records Record[]
@@id([eventcode, itemcode])
@@index([eventcode])
@@index([itemcode])
}
model Receipt {
id String @id // client-generated uuid
createdAt DateTime
total Int
event Event @relation(fields: [eventcode], references: [code])
eventcode String
user User @relation(fields: [userId], references: [id])
userId String
records Record[]
@@index([eventcode])
@@index([userId])
}
model Record {
receipt Receipt @relation(fields: [receiptId], references: [id])
receiptId String @map("receipt_id")
display Display @relation(fields: [eventcode, itemcode], references: [eventcode, itemcode])
eventcode String
itemcode String
index Int
count Int
dedication Boolean
@@id([receiptId, index])
@@index([receiptId])
@@index([eventcode])
@@index([itemcode])
@@index([eventcode, itemcode])
}