2026-01-20 17:20:13 +01:00
|
|
|
// 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 User {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
email String @unique
|
|
|
|
|
password String
|
|
|
|
|
name String?
|
2026-02-08 14:21:07 +01:00
|
|
|
photoUrl String?
|
2026-01-22 18:53:23 +01:00
|
|
|
roleId String?
|
|
|
|
|
role Role? @relation(fields: [roleId], references: [id], onDelete: SetNull)
|
2026-01-20 17:20:13 +01:00
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
2026-01-21 18:13:35 +01:00
|
|
|
conversations ConversationParticipant[]
|
|
|
|
|
sentMessages Message[]
|
2026-02-08 14:16:55 +01:00
|
|
|
notifications Notification[]
|
2026-01-20 17:20:13 +01:00
|
|
|
}
|
2026-01-20 18:08:06 +01:00
|
|
|
|
2026-01-22 18:53:23 +01:00
|
|
|
model Role {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
name String @unique
|
|
|
|
|
description String?
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
users User[]
|
|
|
|
|
permissions RolePermission[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Permission {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
name String @unique
|
|
|
|
|
description String?
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
roles RolePermission[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model RolePermission {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
roleId String
|
|
|
|
|
role Role @relation(fields: [roleId], references: [id], onDelete: Cascade)
|
|
|
|
|
permissionId String
|
|
|
|
|
permission Permission @relation(fields: [permissionId], references: [id], onDelete: Cascade)
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
|
|
|
|
|
@@unique([roleId, permissionId])
|
|
|
|
|
@@index([roleId])
|
|
|
|
|
@@index([permissionId])
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-20 18:08:06 +01:00
|
|
|
model Chauffeur {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
nom String
|
|
|
|
|
prenom String
|
|
|
|
|
dateNaissance DateTime
|
|
|
|
|
telephone String
|
|
|
|
|
email String
|
|
|
|
|
adresse String
|
|
|
|
|
heuresContrat Int @default(35) // Nombre d'heures dans le contrat (ex: 35h)
|
|
|
|
|
dateDebutContrat DateTime // Date de début du contrat
|
|
|
|
|
dateFinContrat DateTime? // Date de fin du contrat (modifiable à tout moment, peut être null)
|
|
|
|
|
heuresRestantes Int @default(35) // Heures restantes (calculé/géré séparément)
|
|
|
|
|
status String @default("Disponible") // Disponible, Vacances, Arrêt Maladie
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
2026-02-15 14:36:28 +01:00
|
|
|
trajets Trajet[]
|
2026-01-20 18:08:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model UniversPro {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
nom String
|
|
|
|
|
prenom String
|
|
|
|
|
telephone String
|
|
|
|
|
email String
|
|
|
|
|
adresse String // Adresse de résidence
|
|
|
|
|
nomEntreprise String
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
2026-02-15 14:36:28 +01:00
|
|
|
trajets Trajet[]
|
2026-01-20 18:08:06 +01:00
|
|
|
}
|
2026-01-20 19:02:49 +01:00
|
|
|
|
|
|
|
|
model Adherent {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
nom String
|
|
|
|
|
prenom String
|
|
|
|
|
dateNaissance DateTime
|
|
|
|
|
adresse String // Adresse de résidence
|
|
|
|
|
email String
|
|
|
|
|
telephone String
|
|
|
|
|
// Informations complémentaires
|
|
|
|
|
situation String? // Sélecteur à option
|
|
|
|
|
prescripteur String? // Sélecteur à option
|
|
|
|
|
facturation String? // Sélecteur à option
|
2026-01-22 19:25:25 +01:00
|
|
|
forfait String? // Sélecteur à option (formule avec prix par trajet)
|
2026-01-20 19:02:49 +01:00
|
|
|
commentaire String? // Texte libre
|
|
|
|
|
telephoneSecondaire String? // Téléphone secondaire
|
|
|
|
|
instructions String? // Instructions
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
2026-02-15 14:36:28 +01:00
|
|
|
trajets Trajet[]
|
|
|
|
|
participations ParticipationFinanciere[]
|
2026-01-21 17:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Trajet {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
date DateTime // Date et heure du trajet
|
|
|
|
|
adresseDepart String // Adresse de départ
|
|
|
|
|
adresseArrivee String // Adresse d'arrivée
|
|
|
|
|
commentaire String? // Commentaire optionnel
|
2026-01-22 19:25:25 +01:00
|
|
|
instructions String? // Instructions pour le trajet
|
2026-01-21 18:13:35 +01:00
|
|
|
statut String @default("Planifié") // Planifié, En cours, Terminé, Annulé, Validé
|
|
|
|
|
archived Boolean @default(false) // Indique si le trajet est archivé
|
2026-01-21 17:34:48 +01:00
|
|
|
adherentId String // Référence à l'adhérent
|
|
|
|
|
adherent Adherent @relation(fields: [adherentId], references: [id])
|
|
|
|
|
chauffeurId String? // Référence au chauffeur (optionnel)
|
|
|
|
|
chauffeur Chauffeur? @relation(fields: [chauffeurId], references: [id])
|
2026-02-15 14:36:28 +01:00
|
|
|
universProId String? // Référence à l'univers pro (optionnel - pour facturation entreprise)
|
|
|
|
|
universPro UniversPro? @relation(fields: [universProId], references: [id], onDelete: SetNull)
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
participations ParticipationFinanciere[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model ParticipationFinanciere {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
trajetId String @unique
|
|
|
|
|
trajet Trajet @relation(fields: [trajetId], references: [id], onDelete: Cascade)
|
|
|
|
|
adherentId String
|
|
|
|
|
adherent Adherent @relation(fields: [adherentId], references: [id], onDelete: Cascade)
|
|
|
|
|
destinataireEmail String // Email du destinataire du paiement (adhérent ou univers pro)
|
|
|
|
|
destinataireNom String // Nom affiché du destinataire
|
|
|
|
|
destinataireType String // "adherent" | "univers_pro"
|
|
|
|
|
montant Float? // Montant de la participation (optionnel)
|
|
|
|
|
filePath String? // Chemin vers le PDF généré
|
|
|
|
|
complement String? // Informations complémentaires (éditable)
|
|
|
|
|
statut String @default("en_attente") // en_attente, envoye, paye, archive
|
2026-01-21 17:34:48 +01:00
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
2026-01-20 19:02:49 +01:00
|
|
|
}
|
2026-01-21 18:13:35 +01:00
|
|
|
|
|
|
|
|
model Conversation {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
name String? // Nom pour les groupes (null pour les conversations individuelles)
|
|
|
|
|
type String @default("direct") // "direct" ou "group"
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
participants ConversationParticipant[]
|
|
|
|
|
messages Message[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model ConversationParticipant {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
conversationId String
|
|
|
|
|
conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
|
|
|
|
userId String
|
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
|
joinedAt DateTime @default(now())
|
|
|
|
|
lastReadAt DateTime? // Dernière fois que l'utilisateur a lu les messages
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
|
|
|
|
|
@@unique([conversationId, userId])
|
|
|
|
|
@@index([userId])
|
|
|
|
|
@@index([conversationId])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Message {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
conversationId String
|
|
|
|
|
conversation Conversation @relation(fields: [conversationId], references: [id], onDelete: Cascade)
|
|
|
|
|
senderId String
|
|
|
|
|
sender User @relation(fields: [senderId], references: [id])
|
|
|
|
|
content String? // Contenu textuel du message (peut être null si seulement des fichiers)
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
files MessageFile[]
|
|
|
|
|
|
|
|
|
|
@@index([conversationId, createdAt])
|
|
|
|
|
@@index([senderId])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model MessageFile {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
messageId String
|
|
|
|
|
message Message @relation(fields: [messageId], references: [id], onDelete: Cascade)
|
|
|
|
|
filename String // Nom original du fichier
|
|
|
|
|
filepath String // Chemin de stockage du fichier
|
|
|
|
|
fileType String // Type MIME du fichier
|
|
|
|
|
fileSize Int // Taille en bytes
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
|
|
|
|
|
@@index([messageId])
|
|
|
|
|
}
|
2026-01-22 18:53:23 +01:00
|
|
|
|
|
|
|
|
model AdherentOption {
|
|
|
|
|
id String @id @default(cuid())
|
2026-01-22 19:25:25 +01:00
|
|
|
type String // "situation", "prescripteur", "facturation", "forfait"
|
2026-01-22 18:53:23 +01:00
|
|
|
value String // La valeur de l'option
|
|
|
|
|
order Int @default(0) // Ordre d'affichage
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
|
|
|
|
|
@@unique([type, value])
|
|
|
|
|
@@index([type])
|
|
|
|
|
}
|
2026-02-08 14:16:55 +01:00
|
|
|
|
|
|
|
|
model Notification {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
userId String // Utilisateur destinataire de la notification
|
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
|
type String // "message", "trajet_created", "trajet_cancelled", "trajet_completed"
|
|
|
|
|
title String // Titre de la notification
|
|
|
|
|
message String // Message de la notification
|
|
|
|
|
read Boolean @default(false) // Indique si la notification a été lue
|
|
|
|
|
link String? // Lien optionnel vers la ressource (ex: /dashboard/messagerie, /dashboard/calendrier)
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
|
|
|
|
|
@@index([userId, read])
|
|
|
|
|
@@index([userId, createdAt])
|
|
|
|
|
}
|