Move to zenstack for table inheritance
This commit is contained in:
+133
@@ -0,0 +1,133 @@
|
||||
// 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 DrinkType {
|
||||
Drink
|
||||
Beer
|
||||
Wine
|
||||
Soda
|
||||
}
|
||||
|
||||
enum ContainerType {
|
||||
BeerBottle
|
||||
WineBottle
|
||||
PlasticBottle
|
||||
Can
|
||||
Carton
|
||||
}
|
||||
|
||||
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?
|
||||
|
||||
containers Container[]
|
||||
|
||||
@@delegate(type)
|
||||
|
||||
@@allow('all', true)
|
||||
}
|
||||
|
||||
model Beer extends Drink {
|
||||
style_id Int
|
||||
style BeerStyle @relation(fields: [style_id], references: [id])
|
||||
|
||||
ibu Float?
|
||||
|
||||
@@allow('all', true)
|
||||
}
|
||||
|
||||
model BeerStyle {
|
||||
id Int @id @default(autoincrement())
|
||||
|
||||
name String @unique
|
||||
|
||||
beers Beer[]
|
||||
|
||||
@@allow('all', true)
|
||||
}
|
||||
|
||||
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('all', true)
|
||||
}
|
||||
|
||||
model WineStyle {
|
||||
id Int @id @default(autoincrement())
|
||||
|
||||
name String @unique
|
||||
|
||||
wines Wine[]
|
||||
|
||||
@@allow('all', true)
|
||||
}
|
||||
|
||||
model Soda extends Drink {
|
||||
carbonated Boolean
|
||||
|
||||
@@allow('all', true)
|
||||
}
|
||||
|
||||
model Container {
|
||||
barcode String @id
|
||||
|
||||
drink_id Int
|
||||
drink Drink @relation(fields: [drink_id], references: [id])
|
||||
|
||||
type ContainerType
|
||||
volume Int
|
||||
portions Int?
|
||||
|
||||
inventory Int @default(0)
|
||||
|
||||
@@allow('all', true)
|
||||
}
|
||||
|
||||
model Manufacturer {
|
||||
id Int @id @default(autoincrement())
|
||||
|
||||
country_id String
|
||||
country Country @relation(fields: [country_id], references: [code])
|
||||
|
||||
name String @unique
|
||||
image String?
|
||||
|
||||
drinks Drink[]
|
||||
|
||||
@@allow('all', true)
|
||||
}
|
||||
|
||||
model Country {
|
||||
code String @id
|
||||
name String
|
||||
|
||||
manufacturers Manufacturer[]
|
||||
|
||||
@@allow('all', true)
|
||||
}
|
||||
Reference in New Issue
Block a user