-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
69 lines (56 loc) · 1.56 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
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
enum Role {
ADMIN
STORE_MANAGER
USER
}
model User {
id String @id @default(uuid())
email String @unique
password String
role Role @default(USER)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Book {
id String @id @default(uuid())
title String
author String
price Float?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
//! Relation to pivot table
BookstoreBook BookstoreBook[]
}
model Bookstore {
id String @id @default(uuid())
name String @unique
location String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
//! Relation to pivot table
BookstoreBook BookstoreBook[]
}
model BookstoreBook {
id String @id @default(uuid())
quantity Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
//! Foreign keys
bookstoreId String
bookId String
//! Relations
bookstore Bookstore @relation(fields: [bookstoreId], references: [id])
book Book @relation(fields: [bookId], references: [id])
@@unique([bookstoreId, bookId], map: "unique_bookstore_book")
}