247 lines
5.0 KiB
Plaintext
247 lines
5.0 KiB
Plaintext
// 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("DATABASE_URL")
|
|
}
|
|
|
|
enum UserType {
|
|
User
|
|
Scanner
|
|
Admin
|
|
}
|
|
|
|
enum DrinkType {
|
|
Drink
|
|
Beer
|
|
Wine
|
|
Soda
|
|
Cocktail
|
|
}
|
|
|
|
enum ContainerType {
|
|
BeerBottle
|
|
WineBottle
|
|
PlasticBottle
|
|
Can
|
|
Carton
|
|
Keg
|
|
}
|
|
|
|
model Drink {
|
|
id Int @id @default(autoincrement())
|
|
slug String @unique
|
|
|
|
manufacturer_id Int
|
|
manufacturer Manufacturer @relation(fields: [manufacturer_id], references: [id])
|
|
|
|
type DrinkType
|
|
|
|
name String @unique
|
|
description String
|
|
abv Float
|
|
image String?
|
|
link String?
|
|
|
|
gluten Boolean
|
|
lactose Boolean
|
|
organic Boolean
|
|
sugar Boolean @default(true)
|
|
|
|
containers Container[]
|
|
|
|
@@delegate(type)
|
|
|
|
@@allow('read', true)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
model Beer extends Drink {
|
|
style_id Int
|
|
style BeerStyle @relation(fields: [style_id], references: [id])
|
|
|
|
ibu Float?
|
|
|
|
glass Boolean @default(false)
|
|
|
|
@@allow('read', true)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
model BeerStyle {
|
|
id Int @id @default(autoincrement())
|
|
|
|
name String @unique
|
|
color String
|
|
|
|
beers Beer[]
|
|
|
|
@@allow('read', true)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
model Wine extends Drink {
|
|
style_id Int
|
|
style WineStyle @relation(fields: [style_id], references: [id])
|
|
|
|
heavy_score Int?
|
|
tannine_score Int?
|
|
dry_score Int?
|
|
fresh_score Int?
|
|
notes String?
|
|
|
|
@@allow('read', true)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
model WineStyle {
|
|
id Int @id @default(autoincrement())
|
|
|
|
name String @unique
|
|
color String
|
|
|
|
wines Wine[]
|
|
|
|
@@allow('read', true)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
model Soda extends Drink {
|
|
carbonated Boolean
|
|
|
|
@@allow('read', true)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
model Cocktail extends Drink {
|
|
mix Boolean
|
|
|
|
@@allow('read', true)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
model Container {
|
|
id Int @id @default(autoincrement())
|
|
barcode String? @unique
|
|
|
|
drink_id Int
|
|
drink Drink @relation(fields: [drink_id], references: [id])
|
|
|
|
section_id Int
|
|
section Section @relation(fields: [section_id], references: [id])
|
|
|
|
type ContainerType
|
|
volume Int
|
|
portions Int?
|
|
price Float @default(0.0)
|
|
|
|
inventory Int @default(0)
|
|
|
|
checkouts History[]
|
|
|
|
@@allow('read', true)
|
|
@@allow('update', auth() != null)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
model Section {
|
|
id Int @id @default(autoincrement())
|
|
name String @unique
|
|
|
|
containers Container[]
|
|
|
|
@@allow('read', true)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
model Manufacturer {
|
|
id Int @id @default(autoincrement())
|
|
|
|
country_id String
|
|
country Country @relation(fields: [country_id], references: [code])
|
|
|
|
name String @unique
|
|
description String?
|
|
image String?
|
|
|
|
drinks Drink[]
|
|
|
|
@@allow('read', true)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
model Country {
|
|
code String @id
|
|
name String
|
|
|
|
manufacturers Manufacturer[]
|
|
|
|
@@allow('read', true)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
model History {
|
|
id Int @id @default(autoincrement())
|
|
|
|
container_id Int
|
|
container Container @relation(fields: [container_id], references: [id])
|
|
|
|
checkoutAt DateTime @default(now())
|
|
inventoryAfter Int
|
|
|
|
@@allow('read', true)
|
|
@@allow('create', auth().type == Scanner)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
// Authentication
|
|
model User {
|
|
id Int @id @default(autoincrement())
|
|
username String @unique
|
|
password String @password @omit
|
|
type UserType
|
|
|
|
sessions Session[]
|
|
|
|
@@allow('all', auth() == this)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(uuid())
|
|
createdAt DateTime @default(now())
|
|
user_id Int?
|
|
user User? @relation(fields: [user_id], references: [id])
|
|
data String
|
|
|
|
@@allow('all', auth().id == user.id)
|
|
@@allow('all', auth().type == Admin)
|
|
}
|
|
|
|
model Suggestion {
|
|
id Int @id @default(autoincrement())
|
|
createdAt DateTime @default(now())
|
|
name String?
|
|
content String
|
|
resolved Boolean @default(false)
|
|
|
|
@@allow('all', true)
|
|
}
|
|
|
|
model Report {
|
|
id Int @id @default(autoincrement())
|
|
createdAt DateTime @default(now())
|
|
|
|
name String @unique
|
|
dateStart DateTime
|
|
dateEnd DateTime
|
|
|
|
file String
|
|
|
|
@@allow('all', auth().type == Admin)
|
|
} |