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

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

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

model Conversation {
  id        String    @id @default(cuid())
  title     String    @default("New Conversation")
  userId    String?
  user      User?     @relation(fields: [userId], references: [id], onDelete: SetNull)
  messages  Message[]
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
}

model Message {
  id             String       @id @default(cuid())
  role           String       // "user" | "assistant" | "system"
  content        String
  audioUrl       String?
  conversationId String
  conversation   Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
  createdAt      DateTime     @default(now())
}
