// 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 = "sqlite"
  url      = env("DATABASE_URL")
}

model Team {
  id              String   @id
  icon            String
  description     String?
  members         User[]
  balanceByIncome Boolean? @default(value: false)
}

model User {
  id           String    @id @default(uuid())
  createdAt    DateTime  @default(now())
  updatedAt    DateTime  @updatedAt
  username     String    @unique
  icon         String
  passwordHash String
  teamId       String
  team         Team      @relation(fields: [teamId], references: [id], onDelete: Cascade)
  expenses     Expense[]
  theme        String?
  avgIncome    Int?
}

model Expense {
  id          String   @id @default(uuid())
  userId      String
  user        User     @relation(fields: [userId], references: [id], onDelete: Cascade)
  teamId      String
  createdAt   DateTime @default(now())
  updatedAt   DateTime @updatedAt
  description String
  amount      Float
}
