generator client {
  provider = "prisma-client-js"
  binaryTargets = ["native", "linux-musl-arm64-openssl-3.0.x"]
}

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

model User {
  id       Int      @id @default(autoincrement())
  username String   @unique
  password String
  role     String   @default("USER") // ADMIN, USER
  plates   Plate[]
}

model Plate {
  id        Int      @id @default(autoincrement())
  number    String   @unique
  owner     String?
  status    String   @default("PENDING") // PENDING, ALLOWED, DENIED
  createdAt DateTime @default(now())
  addedBy   User?    @relation(fields: [addedById], references: [id])
  addedById Int?
}

model AccessLog {
  id          Int      @id @default(autoincrement())
  plateNumber String
  accessStatus String   // GRANTED, DENIED, UNKNOWN
  timestamp   DateTime @default(now())
}
