From e781de64a1dbe36725c405093ec38a5b14f5ee4d Mon Sep 17 00:00:00 2001 From: Elias Bennour Date: Sun, 25 May 2025 15:39:58 +0200 Subject: [PATCH] update prisma schema --- prisma/schema.prisma | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 8ac7e60..dc889de 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -17,15 +17,18 @@ model Account { providerAccountId String refresh_token String? @db.Text access_token String? @db.Text - expires_at Int? + expires_at Int? // Üblicherweise für access_token Ablauf (in Sekunden seit Unix-Epoche) token_type String? scope String? id_token String? @db.Text session_state String? + refresh_expires_in Int? // NEU: Lebensdauer des Refresh Tokens in Sekunden + user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([provider, providerAccountId]) + @@index([userId]) // Index für userId hinzugefügt für bessere Abfrageleistung } model Session { @@ -34,32 +37,35 @@ model Session { userId String expires DateTime user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@index([userId]) // Index für userId hinzugefügt } model User { id String @id @default(cuid()) name String? email String? @unique - emailVerified DateTime? // Von NextAuth benötigt + emailVerified DateTime? image String? - password String? // Für CredentialsProvider + password String? role String? @default("user") balance Decimal? @default(0.00) @db.Decimal(10, 2) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt - // Felder für den Freigabeprozess - isApproved Boolean @default(false) // Ist der Benutzer vom Admin freigegeben? - approvedAt DateTime? // Wann wurde der Benutzer freigegeben? - approvedByAdminId String? // ID des Admins, der den Benutzer freigegeben hat + isApproved Boolean @default(false) + approvedAt DateTime? + approvedByAdminId String? approvedByAdmin User? @relation("AdminApprovals", fields: [approvedByAdminId], references: [id], onDelete: SetNull) + isLocked Boolean @default(false) + accounts Account[] sessions Session[] transactions Transaction[] triggeredTransactions Transaction[] @relation("AdminTransactions") - approvedUsers User[] @relation("AdminApprovals") // Benutzer, die dieser Admin freigegeben hat + approvedUsers User[] @relation("AdminApprovals") } model VerificationToken { @@ -84,5 +90,5 @@ model Transaction { triggeredByAdmin User? @relation("AdminTransactions", fields: [triggeredByAdminId], references: [id], onDelete: SetNull) @@index([triggeredByAdminId]) - @@index([userId]) // Index für userId in Transaction hinzugefügt + @@index([userId]) }