mirror of
https://github.com/Since-3/Kuma.git
synced 2026-10-12 21:41:17 +00:00
169 lines
No EOL
4.6 KiB
Text
169 lines
No EOL
4.6 KiB
Text
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
directUrl = env("DIRECT_URL")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
name String?
|
|
complaints String?
|
|
birthday DateTime?
|
|
plz String?
|
|
city String?
|
|
street String?
|
|
houseNumber String?
|
|
email String @unique
|
|
tel String?
|
|
gender String?
|
|
is2FA Boolean @default(false)
|
|
isSendingMail Boolean @default(false)
|
|
isNewsletter Boolean @default(false)
|
|
pbSrc String?
|
|
isValid Boolean @default(false)
|
|
trainings UserTraining[]
|
|
courseBookings CourseBooking[]
|
|
createdAt DateTime? @default(now())
|
|
updatedAt DateTime? @updatedAt
|
|
}
|
|
|
|
model Employee {
|
|
id String @id @default(uuid())
|
|
firstName String?
|
|
lastName String?
|
|
email String @unique
|
|
is2FA Boolean @default(false)
|
|
isSendingMail Boolean @default(false)
|
|
pbSrc String?
|
|
status String?
|
|
roles String[] @default([])
|
|
locations String[] @default([])
|
|
permissions Json?
|
|
affiliation String?
|
|
label String?
|
|
qualification String?
|
|
authorization Json?
|
|
onboardingToken String? @unique
|
|
onboardingTokenExpiry DateTime?
|
|
isOnboarded Boolean @default(false)
|
|
createdBy String? // Manager ID who created the employee
|
|
trainings UserTraining[]
|
|
createdAt DateTime? @default(now())
|
|
updatedAt DateTime? @updatedAt
|
|
|
|
@@index([createdBy])
|
|
}
|
|
|
|
model UserTraining {
|
|
userId String
|
|
employeeId String
|
|
employee Employee @relation(fields: [employeeId], references: [id])
|
|
user User @relation(fields: [userId], references: [id])
|
|
@@id([userId, employeeId])
|
|
}
|
|
|
|
model Manager {
|
|
id String @id @default(uuid())
|
|
firstName String
|
|
lastName String
|
|
tel String?
|
|
email String @unique
|
|
is2FA Boolean @default(false)
|
|
isSendingMail Boolean @default(false)
|
|
pbSrc String?
|
|
businesses Business[]
|
|
createdAt DateTime? @default(now())
|
|
updatedAt DateTime? @updatedAt
|
|
}
|
|
|
|
model Business {
|
|
id String @id @default(uuid())
|
|
managerId String
|
|
name String
|
|
address String
|
|
email String
|
|
title String
|
|
ustId String?
|
|
banking String?
|
|
plan String?
|
|
subscription Json?
|
|
slug String? @unique
|
|
isPublic Boolean @default(false)
|
|
stripeAccountId String? @unique // Stripe Connect Account ID
|
|
stripeAccountStatus String? // "pending" | "active" | "restricted"
|
|
manager Manager @relation(fields: [managerId], references: [id])
|
|
courses Course[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([managerId])
|
|
}
|
|
|
|
model Course {
|
|
id String @id @default(uuid())
|
|
name String
|
|
sport String[]
|
|
level String @default("any")
|
|
date DateTime
|
|
timeFrom String // Anfangszeit
|
|
timeTo String // Endzeit
|
|
trainers String[] // Array of trainer IDs
|
|
room String
|
|
description String // Rich text HTML content
|
|
maxParticipants Int // Maximum number of participants
|
|
price Float @default(10.0) // Preis in Euro
|
|
isStandingOrder Boolean @default(false)
|
|
frequency String? // daily, weekly, biweekly, monthly, custom
|
|
weekdays String[] // For custom frequency
|
|
status String @default("draft") // draft, published
|
|
createdBy String // Manager ID who created the course
|
|
businessId String?
|
|
coverImage String?
|
|
business Business? @relation(fields: [businessId], references: [id], onDelete: SetNull)
|
|
bookings CourseBooking[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([createdBy])
|
|
@@index([date])
|
|
@@index([status])
|
|
@@index([businessId])
|
|
}
|
|
|
|
model Room {
|
|
id String @id @default(uuid())
|
|
name String
|
|
createdBy String // Manager ID who created the room
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([createdBy])
|
|
}
|
|
|
|
model CourseBooking {
|
|
id String @id @default(uuid())
|
|
courseId String
|
|
userId String
|
|
paymentStatus String @default("pending") // "pending" | "paid" | "failed" | "refunded"
|
|
stripeSessionId String? @unique
|
|
stripePaymentIntentId String? @unique
|
|
amountPaid Float? // tatsächlich gezahlter Betrag in EUR
|
|
platformFee Float? // unsere Service-Fee in EUR
|
|
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([courseId, userId]) // Ein User kann sich nur einmal pro Kurs anmelden
|
|
@@index([courseId])
|
|
@@index([userId])
|
|
} |