generator client {
  provider = "prisma-client-js"
  output   = "../generated/prisma"
}

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

model User {
  id        String   @id @default(cuid())
  name      String?
  email     String?  @unique
  password  String?
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  ApiKey    ApiKey[]
}

model ApiKey {
  id          String    @id @default(cuid())
  User        User?     @relation(fields: [userId], references: [id])
  userId      String
  name        String
  key         String    @unique @db.Text
  description String?
  expiredAt   DateTime?
  createdAt   DateTime  @default(now())
  updatedAt   DateTime  @updatedAt
}

model WebHook {
  id          String   @id @default(cuid())
  name        String?
  description String?
  url         String
  payload     String?  @default("{}")
  method      String   @default("POST")
  headers     String?  @default("{}")
  apiToken    String?
  retries     Int?     @default(3)
  enabled     Boolean  @default(true)
  replay      Boolean  @default(false)
  replayKey   String?
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
}
