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

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

model SnapshotTask {
  id          String   @id @default(uuid())
  status      String   @default("PENDING")
  storageType String
  storagePath String
  targets     String   // JSON: ["POSTGRES","REDIS"]
  totalSize   BigInt   @default(0)
  error       String?
  startedAt   DateTime?
  completedAt DateTime?
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt

  details SnapshotDetail[]

  @@map("snapshot_tasks")
}

model SnapshotDetail {
  id          String   @id @default(uuid())
  taskId      String
  target      String
  status      String   @default("PENDING")
  progress    Float    @default(0)
  progressMsg String?
  fileSize    BigInt   @default(0)
  fileName    String?
  error       String?
  startedAt   DateTime?
  completedAt DateTime?
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt

  task SnapshotTask @relation(fields: [taskId], references: [id], onDelete: Cascade)

  @@index([taskId])
  @@map("snapshot_details")
}
