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

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

model User {
  id           String   @id @default(uuid())
  account      String   @unique
  password     String
  isCreator    Boolean  @default(false)
  creatorName  String?
  libraryName  String?
  boundCreator String?
  createdAt    DateTime @default(now())
  updatedAt    DateTime @updatedAt

  roles  Role[]
  orders Order[]
}

model Role {
  id            String   @id @default(uuid())
  creatorId     String
  displayName   String
  gender        String   @default("unknown")
  age           String?
  relationship  String?
  personality   String
  background    String
  speechStyle   String
  likes         String?
  dislikes      String?
  memories      String?
  secrets       String?
  greeting      String
  systemPrompt  String?
  model         String   @default("gpt-4o")
  temperature   Float    @default(0.8)
  maxTokens     Int      @default(2048)
  enableMemory  Boolean  @default(true)
  enableTools   Boolean  @default(false)
  agentId       String?
  soulMd        String?
  configYaml    String?
  avatar        String?
  desc          String?
  price         Float    @default(0)
  status        String   @default("running")
  createdAt     DateTime @default(now())
  updatedAt     DateTime @updatedAt

  creator User   @relation(fields: [creatorId], references: [id])
  orders Order[]
}

model Order {
  id        String   @id @default(uuid())
  userId    String
  roleId    String
  amount    Float
  status    String   @default("paid")
  createdAt DateTime @default(now())

  user User @relation(fields: [userId], references: [id])
  role Role @relation(fields: [roleId], references: [id])
}
