generator dartClient {
  provider = "dart run orm"
  output   = "../../../backend_dart/lib/infrastructure/persistence/db"
}

generator goClient {
  provider = "go run github.com/steebchen/prisma-client-go"
  output   = "../../../backend-go/internal/infrastructure/persistence/db"
}

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

// User Model
model User {
  id          String      @id @default(uuid())
  name        String
  email       String      @unique
  password    String
  projects    Project[] // Beziehung zu Projekten
  timeEntries TimeEntry[] // Beziehung zu Zeiteinträgen
  createdAt   DateTime    @default(now())
  updatedAt   DateTime    @updatedAt
}

// Project Model
model Project {
  id          String      @id @default(uuid())
  name        String
  description String?
  clientId    String?
  tasks       Task[] // Beziehung zu Aufgaben
  timeEntries TimeEntry[] // Beziehung zu Zeiteinträgen
  user        User        @relation(fields: [userId], references: [id])
  userId      String
  createdAt   DateTime    @default(now())
  updatedAt   DateTime    @updatedAt
}

// TimeEntry Model
model TimeEntry {
  id          String   @id @default(uuid())
  startTime   DateTime
  endTime     DateTime
  description String?
  user        User     @relation(fields: [userId], references: [id])
  userId      String
  project     Project  @relation(fields: [projectId], references: [id])
  projectId   String
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
}

// Task Model (optional)
model Task {
  id          String   @id @default(uuid())
  name        String
  description String?
  project     Project  @relation(fields: [projectId], references: [id])
  projectId   String
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
}
