// 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 = "mysql"
  url      = env("DATABASE_URL")
}

model Recipe {
  id            Int      @id @default(autoincrement())
  recipeNumber  String   @unique @map("Rezeptnummer") @db.VarChar(50)
  title         String   @map("Bezeichnung") @db.Text
  description   String?  @map("Beschreibung") @db.Text
  category      String?  @map("Kategorie") @db.VarChar(100)
  filePath      String?  @map("datei_pfad") @db.VarChar(255)
  preparation   String?  @map("Vorbereitung") @db.Text
  servings      Int      @map("Anzahl") @default(1)
  ingredients   String?  @map("Zutaten") @db.Text
  instructions  String?  @map("Zubereitung") @db.Text
  comment       String?  @map("Kommentar") @db.Text

  // Relations
  images            RecipeImage[]
  ingredientsList   Ingredient[]

  @@map("Rezepte")
}

model Ingredient {
  id           Int    @id @default(autoincrement())
  recipeNumber String @map("rezeptnr") @db.VarChar(20)
  ingredients  String @map("ingr") @db.Text

  // Relations
  recipe Recipe? @relation(fields: [recipeNumber], references: [recipeNumber])

  @@map("ingredients")
}

model RecipeImage {
  id          Int    @id @default(autoincrement())
  recipeId    Int    @map("rezepte_id")
  filePath    String @map("datei_pfad") @db.VarChar(255)

  // Relations
  recipe Recipe? @relation(fields: [recipeId], references: [id])

  @@map("rezepte_bilder")
}