| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- generator client {
- provider = "prisma-client-js"
- binaryTargets = ["native", "windows"]
- }
- datasource mysql {
- provider = "mysql"
- url = env("DATABASE_URL")
- }
- model Station {
- id Int @id @default(autoincrement())
- name String
- long Decimal?
- lat Decimal?
- address String?
- city String?
- country String?
- municipality String?
- description String?
- stationCompanies StationCompany[]
- trajetsDepartingFrom Trajet[] @relation("TrajetsDepartingFrom") // Ajout de la relation inverse
- trajetsArrivingAt Trajet[] @relation("TrajetsArrivingAt") // Ajout de la relation inverse
- }
- model Company {
- id Int @id @default(autoincrement())
- name String @unique
- address String
- managerId Int @unique
- manager User @relation("CompanyManager", fields: [managerId], references: [id])
- employees User[] @relation("CompanyEmployees")
- drivers Driver[] @relation("CompanyDrivers")
- stationCompanies StationCompany[]
- vehicules Vehicule[] @relation("CompanyVehicules")
- trajets Trajet[] @relation("CompanyTrajets") // Relation inverse avec Trajet
- }
- model StationCompany {
- id Int @id @default(autoincrement())
- stationId Int
- companyId Int
- stationChiefId Int
- company Company @relation(fields: [companyId], references: [id])
- stationChief User @relation("UserStationChief", fields: [stationChiefId], references: [id])
- station Station @relation(fields: [stationId], references: [id])
- @@unique([stationId, companyId])
- @@index([companyId], map: "StationCompany_companyId_fkey")
- @@index([stationChiefId], map: "StationCompany_stationChiefId_fkey")
- }
- model Driver {
- id Int @id @default(autoincrement())
- name String @unique
- address String
- telephone String
- companyId Int?
- userId Int @unique
- company Company? @relation("CompanyDrivers", fields: [companyId], references: [id])
- user User @relation("UserDriver", fields: [userId], references: [id])
- vehicules Vehicule[] @relation("DriverVehicules")
- @@index([companyId], map: "Driver_companyId_fkey")
- }
- model User {
- id Int @id @default(autoincrement())
- name String?
- otherName String?
- address String?
- telephone String?
- email String @unique
- password String
- role UserRole @default(USER)
- companyId Int? // Nouveau champ pour la relation employé-entreprise
- company Company? @relation("CompanyEmployees", fields: [companyId], references: [id])
- managedCompany Company? @relation("CompanyManager")
- driver Driver? @relation("UserDriver")
- reservations Reservation[] @relation("UserReservations")
- stationCompanies StationCompany[] @relation("UserStationChief")
- transactions Transaction[] @relation("UserTransactions")
- managedTrajets Trajet[] @relation("TrajetEmployee") // Trajets dont l'utilisateur est responsable
- @@index([companyId], map: "User_companyId_fkey")
- }
- model Vehicule {
- id Int @id @default(autoincrement())
- number_places Int
- color String
- type String
- immatriculation String @unique
- model String
- companyId Int
- driverId Int?
- status VehiculeStatus @default(INACTIF)
- places Place[] @relation("VehiculePlaces")
- trajets Trajet[] @relation("VehiculeTrajets")
- company Company @relation("CompanyVehicules", fields: [companyId], references: [id])
- driver Driver? @relation("DriverVehicules", fields: [driverId], references: [id])
- @@index([companyId], map: "Vehicule_companyId_fkey")
- @@index([driverId], map: "Vehicule_driverId_fkey")
- }
- model Place {
- id Int @id @default(autoincrement())
- number Int
- vehiculeId Int
- isAvailable Boolean @default(true) // Indique si la place est disponible
- occupiedAt DateTime? // Date d'occupation si la place est occupée
- vehicule Vehicule @relation("VehiculePlaces", fields: [vehiculeId], references: [id])
- reservations Reservation[] @relation("PlaceReservations")
- @@index([vehiculeId], map: "Place_vehiculeId_fkey")
- }
- model Trajet {
- id Int @id @default(autoincrement())
- departAt DateTime
- arriveAt DateTime
- // depart String // Ancien champ
- // arrive String // Ancien champ
- departStationId Int // Nouveau champ pour l'ID de la station de départ
- arriveStationId Int // Nouveau champ pour l'ID de la station d'arrivée
- vehiculeId Int
- companyId Int? // Relation directe avec Company (optionnel temporairement)
- employeeId Int? // ID de l'employé responsable du trajet
- pricePerSeat Float @default(0.0) // Prix par place
- reservations Reservation[] @relation("TrajetReservations")
- vehicule Vehicule @relation("VehiculeTrajets", fields: [vehiculeId], references: [id])
- company Company? @relation("CompanyTrajets", fields: [companyId], references: [id]) // Relation directe avec Company
- employee User? @relation("TrajetEmployee", fields: [employeeId], references: [id]) // Relation vers l'employé responsable
- departStation Station @relation("TrajetsDepartingFrom", fields: [departStationId], references: [id]) // Relation vers la station de départ
- arriveStation Station @relation("TrajetsArrivingAt", fields: [arriveStationId], references: [id]) // Relation vers la station d'arrivée
- @@index([vehiculeId], map: "Trajet_vehiculeId_fkey")
- @@index([companyId], map: "Trajet_companyId_fkey") // Index pour la relation avec Company
- @@index([employeeId], map: "Trajet_employeeId_fkey") // Index pour la relation avec l'employé
- @@index([departStationId], map: "Trajet_departStationId_fkey") // Index pour la nouvelle clé étrangère
- @@index([arriveStationId], map: "Trajet_arriveStationId_fkey") // Index pour la nouvelle clé étrangère
- }
- model Reservation {
- id Int @id @default(autoincrement())
- dateAt DateTime
- placeId Int
- userId Int
- trajetId Int
- qrcode Qrcode? @relation("ReservationQrcode")
- place Place @relation("PlaceReservations", fields: [placeId], references: [id])
- trajet Trajet @relation("TrajetReservations", fields: [trajetId], references: [id])
- user User @relation("UserReservations", fields: [userId], references: [id])
- transaction Transaction? @relation("ReservationTransaction")
- @@index([placeId], map: "Reservation_placeId_fkey")
- @@index([trajetId], map: "Reservation_trajetId_fkey")
- @@index([userId], map: "Reservation_userId_fkey")
- }
- model Transaction {
- id String @id @default(uuid())
- amount Float?
- currency String?
- status String?
- provider String?
- reference String?
- metadata Json?
- createdAt DateTime? @default(now())
- updatedAt DateTime? @updatedAt
- userId Int @unique
- reservationId Int @unique
- // Champs PayDunya
- paydunya_token String? @unique
- paydunya_transaction_id String? @unique
- paydunya_invoice_url String?
- payment_method String? // "mobile_money", "card", "bank_transfer"
- payment_type String? // "invoice", "dmp", "softpay"
- paydunya_response Json? // Réponse complète de PayDunya
- webhook_data Json? // Données reçues via webhook
- // Champs CinetPay
- cinetpay_transaction_id String?
- cinetpay_payment_token String?
- cinetpay_payment_url String?
- cinetpay_response Json? // Réponse complète de CinetPay
- cinetpay_webhook_data Json? // Données webhook CinetPay
- cinetpay_payment_method String? // "mobile_money", "credit_card", "wallet"
- cinetpay_operator_id String? // ID de l'opérateur (Orange, MTN, etc.)
- cinetpay_phone_number String? // Numéro de téléphone utilisé
- cinetpay_payment_date DateTime? // Date de paiement confirmée
- reservation Reservation @relation("ReservationTransaction", fields: [reservationId], references: [id])
- user User @relation("UserTransactions", fields: [userId], references: [id])
- @@index([userId], map: "Transaction_userId_fkey")
- @@index([paydunya_token], map: "Transaction_paydunya_token_idx")
- @@index([paydunya_transaction_id], map: "Transaction_paydunya_transaction_id_idx")
- @@index([payment_method], map: "Transaction_payment_method_idx")
- @@index([payment_type], map: "Transaction_payment_type_idx")
- @@index([cinetpay_payment_method], map: "Transaction_cinetpay_payment_method_idx")
- @@index([provider], map: "Transaction_provider_idx")
- @@index([status], map: "Transaction_status_idx")
- }
- model Qrcode {
- id String @id @default(uuid())
- reservationId Int @unique
- createdAt DateTime @default(now())
- scannedAt DateTime?
- value String
- reservation Reservation @relation("ReservationQrcode", fields: [reservationId], references: [id])
- }
- enum UserRole {
- USER
- ADMIN
- DRIVER
- MANAGER
- EMPLOYEE
- }
- enum VehiculeStatus {
- ACTIF
- INACTIF
- MAINTENANCE
- }
|