// 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 = "mysql" } model User { id Int @id @default(autoincrement()) email String @unique password String name String phone String role String @default("USER") // USER or ADMIN createdAt DateTime @default(now()) bookings Booking[] } model Route { id Int @id @default(autoincrement()) departureCity String arrivalCity String durationMinutes Int basePrice Decimal @db.Decimal(10, 2) createdAt DateTime @default(now()) schedules Schedule[] } model Schedule { id Int @id @default(autoincrement()) routeId Int route Route @relation(fields: [routeId], references: [id], onDelete: Cascade) departureTime DateTime arrivalTime DateTime vehicleType String // "Toyota HiAce" or "Executive Bus" capacity Int price Decimal @db.Decimal(10, 2) createdAt DateTime @default(now()) bookings Booking[] } model Booking { id Int @id @default(autoincrement()) bookingCode String @unique // e.g. "TRV-XXXXXX" userId Int? user User? @relation(fields: [userId], references: [id], onDelete: SetNull) scheduleId Int schedule Schedule @relation(fields: [scheduleId], references: [id], onDelete: Cascade) passengerName String passengerEmail String passengerPhone String totalPrice Decimal @db.Decimal(10, 2) status String @default("PENDING") // PENDING, PAID, CANCELLED paymentMethod String? paymentTime DateTime? createdAt DateTime @default(now()) seats BookingSeat[] } model BookingSeat { id Int @id @default(autoincrement()) bookingId Int booking Booking @relation(fields: [bookingId], references: [id], onDelete: Cascade) scheduleId Int seatNumber String // e.g. "1", "2A", etc. @@unique([scheduleId, seatNumber]) } model SystemSetting { id Int @id @default(autoincrement()) key String @unique value String @db.Text }