////////////////////////////////////////////////////////////////////////////////////////////// // DO NOT MODIFY THIS FILE // // This file is automatically generated by ZenStack CLI and should not be manually updated. // ////////////////////////////////////////////////////////////////////////////////////////////// datasource db { provider = "postgresql" url = env("DATABASE_URL") } generator client { provider = "prisma-client-js" } enum UserType { User Scanner Admin } enum DrinkType { Drink Beer Wine Soda Cocktail } enum ContainerType { BeerBottle WineBottle PlasticBottle Can Carton } /// @@delegate(type) /// @@allow('read', true) /// @@allow('all', auth().type == Admin) 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_aux_beer Beer? delegate_aux_wine Wine? delegate_aux_soda Soda? delegate_aux_cocktail Cocktail? } /// @@allow('read', true) /// @@allow('all', auth().type == Admin) /// @@allow('read', true) /// @@allow('all', auth().type == Admin) model Beer { id Int @id() style_id Int style BeerStyle @relation(fields: [style_id], references: [id]) ibu Float? glass Boolean @default(false) delegate_aux_drink Drink @relation(fields: [id], references: [id], onDelete: Cascade, onUpdate: Cascade) } /// @@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) /// @@allow('read', true) /// @@allow('all', auth().type == Admin) model Wine { id Int @id() 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? delegate_aux_drink Drink @relation(fields: [id], references: [id], onDelete: Cascade, onUpdate: Cascade) } /// @@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) /// @@allow('read', true) /// @@allow('all', auth().type == Admin) model Soda { id Int @id() carbonated Boolean delegate_aux_drink Drink @relation(fields: [id], references: [id], onDelete: Cascade, onUpdate: Cascade) } /// @@allow('read', true) /// @@allow('all', auth().type == Admin) /// @@allow('read', true) /// @@allow('all', auth().type == Admin) model Cocktail { id Int @id() mix Boolean delegate_aux_drink Drink @relation(fields: [id], references: [id], onDelete: Cascade, onUpdate: Cascade) } /// @@allow('read', true) /// @@allow('update', auth() != null) /// @@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('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('create', auth().type == Scanner) /// @@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('all', auth() == this) /// @@allow('all', auth().type == Admin) model User { id Int @id() @default(autoincrement()) username String @unique() /// @password /// @omit password String type UserType sessions Session[] } /// @@allow('all', auth().id == user.id) /// @@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 }