// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

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

datasource db {
  provider = "postgresql"
}

model Tenant {
  id                String                 @id @default(uuid())
  name              String
  slug              String                 @unique
  isActive          Boolean                @default(true)
  plan              String                 @default("BASIC") // BASIC, PREMIUM
  settings          Json?                  // e.g. { features: { multiBranch: true, inventory: true }, branding: { primaryColor: "#ec4899", logoUrl: "" } }
  createdAt         DateTime               @default(now())
  updatedAt         DateTime               @updatedAt
  users             User[]
  branches          Branch[]
  patients          Patient[]
  treatmentPackages TreatmentPackage[]
  treatmentPackageLines TreatmentPackageLine[]
  appointments      Appointment[]
  sessionDetails    SessionDetail[]
  products          Product[]
  invoices          Invoice[]
  invoiceItems      InvoiceItem[]
  services          Service[]
  packageTemplates  PackageTemplate[]
  packageTemplateLines PackageTemplateLine[]
  retouchSchedules  RetouchSchedule[]
  cashRegisters     CashRegister[]
  cashMovements     CashMovement[]
  staffProfiles     StaffProfile[]
  commissions       Commission[]
  payrollEntries    PayrollEntry[]
  serviceConsumables ServiceConsumable[]
  inventoryMovements InventoryMovement[]
  campaigns         Campaign[]
  serviceCampaigns  ServiceCampaign[]
  coupons           Coupon[]
  consentDocuments  ConsentDocument[]
  patientPhotos     PatientPhoto[]
  auditLogs         AuditLog[]
  attendances       Attendance[]
  scheduleExceptions ScheduleException[]
  branchStocks      BranchStock[]
}

model Branch {
  id                 String              @id @default(uuid())
  tenantId           String
  tenant             Tenant              @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  name               String
  address            String?
  phone              String?
  isActive           Boolean             @default(true)
  createdAt          DateTime            @default(now())
  updatedAt          DateTime            @updatedAt
  users              User[]
  patients           Patient[]
  appointments       Appointment[]
  invoices           Invoice[]
  cashRegisters      CashRegister[]
  inventoryMovements InventoryMovement[]
  branchStocks               BranchStock[]
  sourceBranchMovements      InventoryMovement[] @relation("SourceBranchMovements")
  destinationBranchMovements InventoryMovement[] @relation("DestinationBranchMovements")

  @@index([tenantId])
}

enum Role {
  SUPER_ADMIN
  ADMIN
  PHYSIO
  AESTHETICIAN
  RECEPTIONIST
}

enum AppointmentStatus {
  PENDIENTE
  CONFIRMADA
  COMPLETADA
  CANCELADA_CON_CARGO
  CANCELADA_SIN_CARGO
  NO_ASISTIO
}

model User {
  id              String         @id @default(uuid())
  tenantId        String
  tenant          Tenant         @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  branchId        String?
  branch          Branch?        @relation(fields: [branchId], references: [id], onDelete: SetNull)
  email           String
  password        String
  name            String
  role            Role           @default(PHYSIO)
  isActive        Boolean        @default(true)
  workingHours    Json?          // e.g. { monday: { start: "09:00", end: "18:00" } }
  appointments    Appointment[]
  openedRegisters CashRegister[] @relation("OpenedBy")
  closedRegisters CashRegister[] @relation("ClosedBy")
  cashMovements   CashMovement[]
  staffProfile    StaffProfile?
  commissions     Commission[]
  payrollEntries  PayrollEntry[]
  auditLogs       AuditLog[]
  attendances     Attendance[]
  scheduleExceptions ScheduleException[]
  onboardingProgress OnboardingProgress?
  createdAt       DateTime       @default(now())
  updatedAt       DateTime       @updatedAt

  @@unique([email, tenantId])
  @@index([tenantId])
  @@index([tenantId, branchId])
}

model Patient {
  id                String             @id @default(uuid())
  tenantId          String
  tenant            Tenant             @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  branchId          String?
  branch            Branch?            @relation(fields: [branchId], references: [id], onDelete: SetNull)
  fullName          String
  phone             String
  email             String?
  consentSigned     Boolean            @default(false)
  medicalHistory    String?            // Supports markdown/rich text
  isActive          Boolean            @default(true)
  treatmentPackages TreatmentPackage[]
  appointments      Appointment[]
  retouchSchedules  RetouchSchedule[]
  invoices          Invoice[]
  consentDocuments  ConsentDocument[]
  patientPhotos     PatientPhoto[]
  createdAt         DateTime           @default(now())
  updatedAt         DateTime           @updatedAt

  @@index([tenantId])
  @@index([tenantId, branchId])
}

model TreatmentPackage {
  id          String                 @id @default(uuid())
  tenantId    String
  tenant      Tenant                 @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  patientId   String
  patient     Patient                @relation(fields: [patientId], references: [id], onDelete: Cascade)
  packageName String
  purchasedAt DateTime               @default(now())
  expiresAt   DateTime
  status      String                 @default("ACTIVE") // ACTIVE, EXPIRED, COMPLETED
  lines       TreatmentPackageLine[]
  createdAt   DateTime               @default(now())
  updatedAt   DateTime               @updatedAt

  @@index([tenantId])
}

model TreatmentPackageLine {
  id             String          @id @default(uuid())
  tenantId       String
  tenant         Tenant          @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  packageId      String
  package        TreatmentPackage @relation(fields: [packageId], references: [id], onDelete: Cascade)
  serviceId      String?
  service        Service?        @relation(fields: [serviceId], references: [id], onDelete: SetNull)
  serviceName    String          // e.g. "Cavitación", "Presoterapia"
  totalSessions  Int
  usedSessions   Int             @default(0)
  sessionDetails SessionDetail[]
  createdAt      DateTime        @default(now())
  updatedAt      DateTime        @updatedAt

  @@index([tenantId])
}

model Appointment {
  id                 String              @id @default(uuid())
  tenantId           String
  tenant             Tenant              @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  branchId           String?
  branch             Branch?             @relation(fields: [branchId], references: [id], onDelete: SetNull)
  patientId          String
  patient            Patient             @relation(fields: [patientId], references: [id], onDelete: Cascade)
  professionalId     String
  professional       User                @relation(fields: [professionalId], references: [id], onDelete: Cascade)
  serviceId          String?
  service            Service?            @relation(fields: [serviceId], references: [id], onDelete: SetNull)
  dateTime           DateTime
  duration           Int                 // in minutes
  status             AppointmentStatus   @default(PENDIENTE)
  cabin              String?
  sessionDetail      SessionDetail?
  invoice            Invoice?
  originalRetouches  RetouchSchedule[]   @relation("OriginalAppointment")
  retouchSchedule    RetouchSchedule?    @relation("RetouchAppointment")
  commission         Commission?
  inventoryMovements InventoryMovement[]
  createdAt          DateTime            @default(now())
  updatedAt          DateTime            @updatedAt

  @@index([tenantId])
  @@index([tenantId, branchId])
}

model SessionDetail {
  id             String                @id @default(uuid())
  tenantId       String
  tenant         Tenant                @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  appointmentId  String                @unique
  appointment    Appointment           @relation(fields: [appointmentId], references: [id], onDelete: Cascade)
  packageLineId  String?
  packageLine    TreatmentPackageLine? @relation(fields: [packageLineId], references: [id], onDelete: SetNull)
  evolutionNotes String?
  measurements   Json?                 // e.g. { weight, waist, hip, leftThigh, rightThigh }
  createdAt      DateTime              @default(now())
  updatedAt      DateTime              @updatedAt

  @@index([tenantId])
}

model Product {
  id                 String              @id @default(uuid())
  tenantId           String
  tenant             Tenant              @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  name               String
  category           String              // 'TRATAMIENTO' | 'PRODUCTO'
  price              Float
  costPrice          Float               @default(0.0)
  stock              Int                 @default(0)
  unit               String              @default("unidad") // unidad, sesión, ml, etc.
  isActive           Boolean             @default(true)
  invoiceItems       InvoiceItem[]
  consumables        ServiceConsumable[]
  inventoryMovements InventoryMovement[]
  branchStocks       BranchStock[]
  createdAt          DateTime            @default(now())
  updatedAt          DateTime            @updatedAt

  @@index([tenantId])
}

enum PaymentMethod {
  EFECTIVO
  TARJETA
  TRANSFERENCIA
  BILLETERA_VIRTUAL
}

enum InvoiceStatus {
  PAGADO
  PENDIENTE
  CANCELADO
}

model Invoice {
  id            String        @id @default(uuid())
  tenantId      String
  tenant        Tenant        @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  branchId      String?
  branch        Branch?       @relation(fields: [branchId], references: [id], onDelete: SetNull)
  patientId     String
  patient       Patient       @relation(fields: [patientId], references: [id], onDelete: Cascade)
  appointmentId String?       @unique
  appointment   Appointment?  @relation(fields: [appointmentId], references: [id], onDelete: SetNull)
  items         InvoiceItem[]
  subtotal      Float
  tax           Float         @default(0)
  total         Float
  paymentMethod PaymentMethod
  reference     String?
  status        InvoiceStatus @default(PAGADO)
  paidAt        DateTime      @default(now())
  cashMovement  CashMovement?
  couponId      String?
  coupon        Coupon?       @relation(fields: [couponId], references: [id], onDelete: SetNull)
  createdAt     DateTime      @default(now())
  updatedAt     DateTime      @updatedAt

  @@index([tenantId])
  @@index([tenantId, branchId])
}

model InvoiceItem {
  id          String   @id @default(uuid())
  tenantId    String
  tenant      Tenant   @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  invoiceId   String
  invoice     Invoice  @relation(fields: [invoiceId], references: [id], onDelete: Cascade)
  productId   String?
  product     Product? @relation(fields: [productId], references: [id], onDelete: SetNull)
  description String
  unitPrice   Float
  quantity    Int      @default(1)
  total       Float
  createdAt   DateTime @default(now())

  @@index([tenantId])
}

enum ServiceCategory {
  FACIAL
  CORPORAL
  FISIOTERAPIA
  ESTETICA
}

enum TreatmentType {
  SINGLE_SESSION
  MULTI_SESSION
  RETOUCHABLE
}

model Service {
  id                String                 @id @default(uuid())
  tenantId          String
  tenant            Tenant                 @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  name              String
  category          ServiceCategory
  treatmentType     TreatmentType          @default(SINGLE_SESSION)
  defaultDuration   Int                    @default(60)
  defaultPrice      Float
  retouchConfig     Json?                  // e.g. { retouchAfterDays: 30, maxRetouches: 1 }
  requiresConsent   Boolean                @default(false)
  contraindications String?
  isActive          Boolean                @default(true)
  packageLines      TreatmentPackageLine[]
  appointments      Appointment[]
  templateLines     PackageTemplateLine[]
  retouchSchedules  RetouchSchedule[]
  consumables       ServiceConsumable[]
  campaigns         ServiceCampaign[]
  consentDocuments  ConsentDocument[]
  createdAt         DateTime               @default(now())
  updatedAt         DateTime               @updatedAt

  @@index([tenantId])
}

model PackageTemplate {
  id           String                 @id @default(uuid())
  tenantId     String
  tenant       Tenant                 @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  name         String
  description  String?
  validityDays Int                    @default(90)
  totalPrice   Float
  isActive     Boolean                @default(true)
  lines        PackageTemplateLine[]
  createdAt    DateTime               @default(now())
  updatedAt    DateTime               @updatedAt

  @@index([tenantId])
}

model PackageTemplateLine {
  id         String          @id @default(uuid())
  tenantId   String
  tenant     Tenant          @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  templateId String
  template   PackageTemplate @relation(fields: [templateId], references: [id], onDelete: Cascade)
  serviceId  String
  service    Service         @relation(fields: [serviceId], references: [id], onDelete: Cascade)
  sessions   Int
  createdAt  DateTime        @default(now())
  updatedAt  DateTime        @updatedAt

  @@index([tenantId])
}

enum RetouchStatus {
  PENDING
  SCHEDULED
  COMPLETED
  EXPIRED
  WAIVED
}

model RetouchSchedule {
  id                    String        @id @default(uuid())
  tenantId              String
  tenant                Tenant        @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  patientId             String
  patient               Patient       @relation(fields: [patientId], references: [id], onDelete: Cascade)
  serviceId             String
  service               Service       @relation(fields: [serviceId], references: [id], onDelete: Cascade)
  originalAppointmentId String
  originalAppointment   Appointment   @relation("OriginalAppointment", fields: [originalAppointmentId], references: [id], onDelete: Cascade)
  retouchAppointmentId  String?       @unique
  retouchAppointment    Appointment?  @relation("RetouchAppointment", fields: [retouchAppointmentId], references: [id], onDelete: SetNull)
  scheduledDate         DateTime
  status                RetouchStatus @default(PENDING)
  retouchNumber         Int           @default(1)
  notes                 String?
  createdAt             DateTime      @default(now())
  updatedAt             DateTime      @updatedAt

  @@index([tenantId])
}

model CashRegister {
  id              String         @id @default(uuid())
  tenantId        String
  tenant          Tenant         @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  branchId        String?
  branch          Branch?        @relation(fields: [branchId], references: [id], onDelete: SetNull)
  openedById      String
  openedBy        User           @relation("OpenedBy", fields: [openedById], references: [id])
  closedById      String?
  closedBy        User?          @relation("ClosedBy", fields: [closedById], references: [id])
  openingDate     DateTime       @default(now())
  closingDate     DateTime?
  initialBalance  Float
  expectedBalance Float
  actualBalance   Float?
  discrepancy     Float?
  status          CashStatus     @default(OPEN)
  notes           String?
  movements       CashMovement[]
  createdAt       DateTime       @default(now())
  updatedAt       DateTime       @updatedAt

  @@index([tenantId])
  @@index([tenantId, branchId])
}

enum CashStatus {
  OPEN
  CLOSED
}

enum MovementType {
  INCOME
  EXPENSE
  ADJUSTMENT
}

model CashMovement {
  id             String       @id @default(uuid())
  tenantId       String
  tenant         Tenant       @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  cashRegisterId String
  cashRegister   CashRegister @relation(fields: [cashRegisterId], references: [id], onDelete: Cascade)
  userId         String
  user           User         @relation(fields: [userId], references: [id])
  type           MovementType
  amount         Float
  description    String
  invoiceId      String?      @unique
  invoice        Invoice?     @relation(fields: [invoiceId], references: [id], onDelete: SetNull)
  createdAt      DateTime     @default(now())

  @@index([tenantId])
}

enum CommissionStatus {
  PENDING
  PAID
  CANCELLED
}

enum PayrollStatus {
  PENDING
  PAID
}

model StaffProfile {
  id             String       @id @default(uuid())
  tenantId       String
  tenant         Tenant       @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  userId         String       @unique
  user           User         @relation(fields: [userId], references: [id], onDelete: Cascade)
  baseSalary     Float        @default(0.0)
  commissionRate Float        @default(0.0) // e.g. 0.10 for 10%
  contractType   ContractType @default(FIXED)
  salesTarget    Float?
  createdAt      DateTime     @default(now())
  updatedAt      DateTime     @updatedAt

  @@index([tenantId])
}

model Commission {
  id            String           @id @default(uuid())
  tenantId      String
  tenant        Tenant           @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  staffId       String
  staff         User             @relation(fields: [staffId], references: [id], onDelete: Cascade)
  appointmentId String           @unique
  appointment   Appointment      @relation(fields: [appointmentId], references: [id], onDelete: Cascade)
  amount        Float
  status        CommissionStatus @default(PENDING)
  payrollId     String?
  payroll       PayrollEntry?    @relation(fields: [payrollId], references: [id], onDelete: SetNull)
  createdAt     DateTime         @default(now())
  updatedAt     DateTime         @updatedAt

  @@index([tenantId])
}

model PayrollEntry {
  id                String        @id @default(uuid())
  tenantId          String
  tenant            Tenant        @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  staffId           String
  staff             User          @relation(fields: [staffId], references: [id], onDelete: Cascade)
  baseSalary        Float
  commissionsAmount Float
  totalPaid         Float
  status            PayrollStatus @default(PENDING)
  periodStart       DateTime
  periodEnd         DateTime
  paidAt            DateTime?
  commissions       Commission[]
  createdAt         DateTime      @default(now())
  updatedAt         DateTime      @updatedAt

  @@index([tenantId])
}

enum InventoryMovementType {
  SESSION_CONSUMPTION
  STOCK_IN
  STOCK_OUT
}

model ServiceConsumable {
  id        String   @id @default(uuid())
  tenantId  String
  tenant    Tenant   @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  serviceId String
  service   Service  @relation(fields: [serviceId], references: [id], onDelete: Cascade)
  productId String
  product   Product  @relation(fields: [productId], references: [id], onDelete: Cascade)
  quantity  Int      // Quantity of product consumed per service session
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  @@unique([serviceId, productId])
  @@index([tenantId])
}

model InventoryMovement {
  id            String                @id @default(uuid())
  tenantId      String
  tenant        Tenant                @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  branchId      String?
  branch        Branch?               @relation(fields: [branchId], references: [id], onDelete: SetNull)
  productId     String
  product       Product               @relation(fields: [productId], references: [id], onDelete: Cascade)
  type          InventoryMovementType
  quantity      Int
  notes         String?
  appointmentId String?
  appointment   Appointment?          @relation(fields: [appointmentId], references: [id], onDelete: SetNull)
  sourceBranchId      String?
  sourceBranch        Branch?               @relation("SourceBranchMovements", fields: [sourceBranchId], references: [id], onDelete: SetNull)
  destinationBranchId String?
  destinationBranch   Branch?               @relation("DestinationBranchMovements", fields: [destinationBranchId], references: [id], onDelete: SetNull)
  createdAt     DateTime              @default(now())

  @@index([tenantId])
  @@index([tenantId, branchId])
}

enum DiscountType {
  PERCENTAGE
  FIXED
}

model Campaign {
  id            String            @id @default(uuid())
  tenantId      String
  tenant        Tenant            @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  name          String
  description   String?
  discountType  DiscountType
  discountValue Float
  startDate     DateTime
  endDate       DateTime
  isActive      Boolean           @default(true)
  services      ServiceCampaign[]
  createdAt     DateTime          @default(now())
  updatedAt     DateTime          @updatedAt

  @@index([tenantId])
}

model ServiceCampaign {
  id         String   @id @default(uuid())
  tenantId   String
  tenant     Tenant   @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  serviceId  String
  service    Service  @relation(fields: [serviceId], references: [id], onDelete: Cascade)
  campaignId String
  campaign   Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
  createdAt  DateTime @default(now())
  updatedAt  DateTime @updatedAt

  @@unique([serviceId, campaignId])
  @@index([tenantId])
}

model Coupon {
  id            String       @id @default(uuid())
  tenantId      String
  tenant        Tenant       @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  code          String       @unique
  description   String?
  discountType  DiscountType
  discountValue Float
  minSubtotal   Float        @default(0)
  startDate     DateTime
  endDate       DateTime
  maxUses       Int
  usedCount     Int          @default(0)
  isActive      Boolean      @default(true)
  invoices      Invoice[]
  createdAt     DateTime     @default(now())
  updatedAt     DateTime     @updatedAt

  @@index([tenantId])
}

model ConsentDocument {
  id            String   @id @default(uuid())
  tenantId      String
  tenant        Tenant   @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  patientId     String
  patient       Patient  @relation(fields: [patientId], references: [id], onDelete: Cascade)
  serviceId     String
  service       Service  @relation(fields: [serviceId], references: [id], onDelete: Cascade)
  signatureData String   // Firma en base64
  signedAt      DateTime @default(now())

  @@index([tenantId])
}

model PatientPhoto {
  id        String   @id @default(uuid())
  tenantId  String
  tenant    Tenant   @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  patientId String
  patient   Patient  @relation(fields: [patientId], references: [id], onDelete: Cascade)
  url       String   // URL de S3 / R2 o fallback local
  type      String   // 'BEFORE' | 'AFTER' | 'EVOLUTION'
  notes     String?
  createdAt DateTime @default(now())

  @@index([tenantId])
  @@index([tenantId, patientId])
}

model AuditLog {
  id        String   @id @default(uuid())
  tenantId  String
  tenant    Tenant   @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  userId    String
  user      User     @relation(fields: [userId], references: [id], onDelete: Cascade)
  action    String   // e.g. 'UPDATE_CLINICAL_NOTE', 'VOID_INVOICE'
  entity    String   // e.g. 'SessionDetail', 'Invoice'
  entityId  String
  details   String?  // Cambios o payload en formato JSON string
  createdAt DateTime @default(now())

  @@index([tenantId])
}

model Attendance {
  id          String   @id @default(uuid())
  tenantId    String
  tenant      Tenant   @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  userId      String
  user        User     @relation(fields: [userId], references: [id], onDelete: Cascade)
  checkIn     DateTime
  checkOut    DateTime?
  status      String   @default("PRESENT") // PRESENT, LATE, ABSENT, JUSTIFIED
  notes       String?
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt

  @@index([tenantId])
  @@index([tenantId, userId])
}

enum ContractType {
  FIXED
  COMMISSION
  MIXED
  FULL_TIME
  PART_TIME
}

model ScheduleException {
  id             String   @id @default(uuid())
  tenantId       String
  tenant         Tenant   @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  professionalId String
  professional   User     @relation(fields: [professionalId], references: [id], onDelete: Cascade)
  date           DateTime // Date of the exception
  isAvailable    Boolean  @default(false) // true = working custom hours, false = off-duty/holiday
  startTime      String?  // e.g. "09:00"
  endTime        String?  // e.g. "14:00"
  reason         String?  // e.g. "Licencia médica", "Feriado"
  createdAt      DateTime @default(now())
  updatedAt      DateTime @updatedAt

  @@index([tenantId])
  @@index([tenantId, professionalId])
}

model BranchStock {
  id        String   @id @default(uuid())
  tenantId  String
  tenant    Tenant   @relation(fields: [tenantId], references: [id], onDelete: Cascade)
  branchId  String
  branch    Branch   @relation(fields: [branchId], references: [id], onDelete: Cascade)
  productId String
  product   Product  @relation(fields: [productId], references: [id], onDelete: Cascade)
  stock     Int      @default(0)
  minStock  Int      @default(0)
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  @@unique([branchId, productId])
  @@index([tenantId])
}

model OnboardingProgress {
  id           String   @id @default(cuid())
  userId       String   @unique
  user         User     @relation(fields: [userId], references: [id], onDelete: Cascade)
  role         String
  currentPhase Int      @default(0)
  currentStep  Int      @default(0)
  completed    Boolean  @default(false)
  dismissed    Boolean  @default(false)
  createdAt    DateTime @default(now())
  updatedAt    DateTime @updatedAt
}
