see comments + dynamic timeout instead of schedule job

This commit is contained in:
Rajpreet0 2026-08-27 19:31:21 +02:00
parent bd10088e26
commit 034e7386c8
7 changed files with 165 additions and 169 deletions

View file

@ -0,0 +1,15 @@
/*
Warnings:
- You are about to drop the column `guestEmail` on the `CourseWaitlistEntry` table. All the data in the column will be lost.
- You are about to drop the column `guestName` on the `CourseWaitlistEntry` table. All the data in the column will be lost.
- Made the column `userId` on table `CourseWaitlistEntry` required. This step will fail if there are existing NULL values in that column.
*/
-- DropIndex
DROP INDEX "CourseWaitlistEntry_courseId_guestEmail_key";
-- AlterTable
ALTER TABLE "CourseWaitlistEntry" DROP COLUMN "guestEmail",
DROP COLUMN "guestName",
ALTER COLUMN "userId" SET NOT NULL;

View file

@ -207,19 +207,21 @@ model CourseBooking {
@@index([guestLeadId])
}
// Bewusst nur für registrierte User (kein guestEmail-Feld): ein
// unauthentifiziertes Gast-Formular würde eine beliebige, nicht verifizierte
// E-Mail-Adresse als Benachrichtigungsempfänger akzeptieren, ohne dass deren
// Kontrolle bestätigt wurde. Der Login-Zwang schließt das und wirkt nebenbei
// als Anreiz zur Registrierung (Lead-Generierung).
model CourseWaitlistEntry {
id String @id @default(uuid())
courseId String
userId String?
guestEmail String? // normalisiert lowercase; null wenn userId gesetzt
guestName String? // optional, nur bei Gast-Einträgen
userId String
notifiedAt DateTime? // Zeitpunkt der letzten "Platz frei"-Benachrichtigung, null = noch nie benachrichtigt
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
user User? @relation(fields: [userId], 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 eintragen (NULL zählt in Postgres nicht als Duplikat, betrifft also nur registrierte User)
@@unique([courseId, guestEmail]) // Dieselbe Gast-E-Mail nur einmal pro Kurs (analog, betrifft nur Gast-Einträge)
@@unique([courseId, userId]) // Ein User kann sich nur einmal pro Kurs eintragen
@@index([courseId])
@@index([userId])
}