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

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

datasource db {
  provider = "sqlite"
}

model User {
  id          String  @id @default(cuid())
  username    String  @unique
  password    String
  accentColor String  @default("blue")
  chats       Chat[]
}

model Chat {
  id        String    @id @default(cuid())
  createdAt DateTime  @default(now())
  updatedAt DateTime  @updatedAt
  title     String
  pinned    Boolean   @default(false)
  userId    String
  user      User      @relation(fields: [userId], references: [id])
  messages  Message[]
}

model Message {
  id        String   @id @default(cuid())
  createdAt DateTime @default(now())
  role      String   // 'user' or 'assistant'
  content   String
  chatId    String
  chat      Chat     @relation(fields: [chatId], references: [id], onDelete: Cascade)
}
