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

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

model Plan {
  id           String   @id @default(cuid())
  title        String
  password     String
  startDate    DateTime
  endDate      DateTime
  instructions String?
  webhookUrl   String?
  notifyAll    Boolean  @default(true)
  feedingPerDay Int     @default(2)
  feedingInterval Int    @default(1)
  litterInterval Int     @default(2)
  createdAt    DateTime @default(now())
  bookings     Booking[]
  pushSubscriptions PushSubscription[]
}

model Booking {
  id         Int      @id @default(autoincrement())
  planId     String
  plan       Plan     @relation(fields: [planId], references: [id])
  date       DateTime
  sitterName String?
  type       String   @default("SITTER") // "SITTER" or "OWNER_HOME"
  completedAt DateTime?
  createdAt  DateTime @default(now())
  
  completionMessage String?
  completionImage   String?

  @@unique([planId, date, sitterName])
}

model PushSubscription {
  id        String   @id @default(cuid())
  planId    String
  plan      Plan     @relation(fields: [planId], references: [id], onDelete: Cascade)
  endpoint  String   @unique
  p256dh    String
  auth      String
  createdAt DateTime @default(now())
}
