generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id    String @id @default(cuid())
  email String @unique
  hashedPassword String
  cars  Car[]
}

model Car {
  id       String   @id @default(cuid())
  user     User     @relation(fields: [userId], references: [id])
  userId   String

  name     String        // User-defined name (e.g. "Red BMW")
  make     String        // Manufacturer (e.g. "BMW")
  model    String        // Model (e.g. "320i")
  year     Int           // Year (e.g. 2019)
  fuelTypes FuelType[]   // Changed from single fuelType to array for hybrid support

  fillUps  FillUp[]
  mileage  MileageEntry[]
}

model FillUp {
  id       String   @id @default(cuid())
  car      Car      @relation(fields: [carId], references: [id], onDelete: Cascade)
  carId    String
  mileage  Int
  liters   Float
  cost     Float
  currency Currency
  date     DateTime @default(now())
  fuelType FuelType // Add fuelType to each fill-up
}

model MileageEntry {
  id      String   @id @default(cuid())
  car      Car     @relation(fields: [carId], references: [id], onDelete: Cascade)
  carId    String
  mileage  Int
  date     DateTime @default(now())
}

model BugReport {
  id      String   @id @default(cuid())
  name    String?
  email   String?
  bug     String
  date    DateTime @default(now())
}

model ImprovementIdea {
  id      String   @id @default(cuid())
  name    String?
  email   String?
  idea    String
  date    DateTime @default(now())
}

model ContactMessage {
  id      String   @id @default(cuid())
  name    String?
  email   String?
  message String
  date    DateTime @default(now())
}

enum FuelType {
  GASOLINE
  DIESEL
  LPG
  ELECTRIC
}

enum Currency {
  EUR
  USD
  RON
  GBP
}
