Set schema to 'passenger'

This commit is contained in:
Stephanos A
2026-05-22 16:21:24 +03:00
parent 672987cd1e
commit 2dad9137dd

View File

@@ -5,6 +5,7 @@ generator client {
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
schemas = ["passenger"]
}
enum UserRole {
@@ -13,6 +14,8 @@ enum UserRole {
SUPERVISOR
ADMIN
STAFF
@@schema("passenger")
}
enum TripStatus {
@@ -22,12 +25,16 @@ enum TripStatus {
ARRIVED
CANCELLED
DELAYED
@@schema("passenger")
}
enum SeatKind {
STANDARD
PREMIUM
ACCESSIBLE
@@schema("passenger")
}
enum SeatStatus {
@@ -35,11 +42,15 @@ enum SeatStatus {
HELD
BOOKED
BLOCKED
@@schema("passenger")
}
enum PassengerCategory {
ADULT
CHILD
@@schema("passenger")
}
enum IdDocumentType {
@@ -47,12 +58,16 @@ enum IdDocumentType {
PASSPORT
DRIVING_LICENSE
OTHER
@@schema("passenger")
}
enum Currency {
ETB
DJF
USD
@@schema("passenger")
}
model SeatClass {
@@ -66,6 +81,8 @@ model SeatClass {
coaches Coach[]
fareRules FareRule[]
routeFareRules RouteFareRule[]
@@schema("passenger")
}
enum BookingStatus {
@@ -76,6 +93,8 @@ enum BookingStatus {
COMPLETED
NO_SHOW
REFUNDED
@@schema("passenger")
}
enum PaymentMethodType {
@@ -84,6 +103,8 @@ enum PaymentMethodType {
EBIRR
CARD
WALLET
@@schema("passenger")
}
enum PaymentIntentStatus {
@@ -93,11 +114,15 @@ enum PaymentIntentStatus {
FAILED
CANCELLED
REFUNDED
@@schema("passenger")
}
enum WalletLedgerType {
CREDIT
DEBIT
@@schema("passenger")
}
enum NotificationCategory {
@@ -106,6 +131,8 @@ enum NotificationCategory {
DISRUPTION
PROMOTION
SYSTEM
@@schema("passenger")
}
enum StopStatus {
@@ -113,18 +140,24 @@ enum StopStatus {
APPROACHING
CURRENT
UPCOMING
@@schema("passenger")
}
enum SupportConversationStatus {
OPEN
RESOLVED
CLOSED
@@schema("passenger")
}
enum SupportSender {
USER
BOT
AGENT
@@schema("passenger")
}
enum LoyaltyTier {
@@ -132,6 +165,8 @@ enum LoyaltyTier {
SILVER
GOLD
PLATINUM
@@schema("passenger")
}
enum LoyaltyLedgerReason {
@@ -140,6 +175,8 @@ enum LoyaltyLedgerReason {
PROMO_BONUS
MANUAL_ADJUSTMENT
EXPIRY
@@schema("passenger")
}
enum FoodOrderStatus {
@@ -148,12 +185,16 @@ enum FoodOrderStatus {
READY
DELIVERED
CANCELLED
@@schema("passenger")
}
enum DevicePlatform {
IOS
ANDROID
WEB
@@schema("passenger")
}
model User {
@@ -180,6 +221,8 @@ model User {
preferences UserPreferences?
auditLogs AuditLog[]
fraudAlerts FraudAlert[]
@@schema("passenger")
}
model Session {
@@ -192,6 +235,8 @@ model Session {
lastActivityAt DateTime @default(now())
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@schema("passenger")
}
model Passenger {
@@ -208,6 +253,8 @@ model Passenger {
travelerProfiles TravelerProfile[]
savedRoutes SavedRoute[]
@@index([userId])
@@schema("passenger")
}
model TravelerProfile {
@@ -220,6 +267,8 @@ model TravelerProfile {
notes String?
createdAt DateTime @default(now())
passenger Passenger @relation(fields: [passengerId], references: [id])
@@schema("passenger")
}
model Station {
@@ -237,6 +286,8 @@ model Station {
stopTimes TripStopTime[]
crowdSignals StationCrowdSignal[]
@@index([city, countryCode])
@@schema("passenger")
}
model Train {
@@ -250,6 +301,8 @@ model Train {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
schedules TrainSchedule[]
@@schema("passenger")
}
model TrainSchedule {
@@ -277,6 +330,8 @@ model TrainSchedule {
menuItems MenuItem[]
journeySegments JourneySegment[]
@@index([departureAt, originStationId])
@@schema("passenger")
}
model TripStopTime {
@@ -291,6 +346,8 @@ model TripStopTime {
schedule TrainSchedule @relation(fields: [scheduleId], references: [id])
station Station @relation(fields: [stationId], references: [id])
@@unique([scheduleId, sequence])
@@schema("passenger")
}
model TripLiveStatus {
@@ -304,6 +361,8 @@ model TripLiveStatus {
platformLabel String?
updatedAt DateTime @updatedAt
schedule TrainSchedule @relation(fields: [scheduleId], references: [id])
@@schema("passenger")
}
model Coach {
@@ -323,6 +382,8 @@ model Coach {
seatClass SeatClass @relation(fields: [seatClassId], references: [id])
seats Seat[]
assignments CoachAssignment[]
@@schema("passenger")
}
model CoachAssignment {
@@ -336,6 +397,8 @@ model CoachAssignment {
coach Coach @relation(fields: [coachId], references: [id])
@@unique([scheduleId, positionNumber])
@@index([scheduleId])
@@schema("passenger")
}
model Seat {
@@ -358,6 +421,8 @@ model Seat {
blocks SeatBlock[]
@@unique([coachId, row, col])
@@unique([coachId, seatNumber])
@@schema("passenger")
}
model SeatHold {
@@ -370,6 +435,8 @@ model SeatHold {
expiresAt DateTime
createdAt DateTime @default(now())
@@index([expiresAt])
@@schema("passenger")
}
model FareRule {
@@ -384,6 +451,8 @@ model FareRule {
validFrom DateTime
validUntil DateTime?
createdAt DateTime @default(now())
@@schema("passenger")
}
model Booking {
@@ -416,6 +485,8 @@ model Booking {
cancellation BookingCancellation?
baggage BaggageBooking[]
@@index([passengerId, status])
@@schema("passenger")
}
model BookingSeat {
@@ -437,6 +508,8 @@ model BookingSeat {
displayFareMinor Int?
booking Booking @relation(fields: [bookingId], references: [id])
seat Seat @relation(fields: [seatId], references: [id])
@@schema("passenger")
}
model PaymentMethod {
@@ -449,6 +522,8 @@ model PaymentMethod {
isDefault Boolean @default(false)
createdAt DateTime @default(now())
@@index([userId, isDefault])
@@schema("passenger")
}
model PaymentIntent {
@@ -477,6 +552,8 @@ model PaymentIntent {
refunds PaymentRefund[]
@@index([providerOrderId])
@@index([providerTxnId])
@@schema("passenger")
}
model PaymentWebhookEvent {
@@ -493,6 +570,8 @@ model PaymentWebhookEvent {
processingError String?
@@unique([provider, externalEventId])
@@index([merchantOrderId])
@@schema("passenger")
}
model PaymentRefund {
@@ -504,6 +583,8 @@ model PaymentRefund {
status String
createdAt DateTime @default(now())
paymentIntent PaymentIntent @relation(fields: [paymentIntentId], references: [id])
@@schema("passenger")
}
model Ticket {
@@ -520,6 +601,8 @@ model Ticket {
validatorId String?
booking Booking @relation(fields: [bookingId], references: [id])
validationLogs GateValidationLog[]
@@schema("passenger")
}
model LoyaltyAccount {
@@ -533,6 +616,8 @@ model LoyaltyAccount {
passenger Passenger @relation(fields: [passengerId], references: [id])
ledger LoyaltyLedgerEntry[]
rewards LoyaltyReward[]
@@schema("passenger")
}
model LoyaltyLedgerEntry {
@@ -544,6 +629,8 @@ model LoyaltyLedgerEntry {
balanceAfter Int
createdAt DateTime @default(now())
account LoyaltyAccount @relation(fields: [accountId], references: [id])
@@schema("passenger")
}
model LoyaltyReward {
@@ -554,6 +641,8 @@ model LoyaltyReward {
available Boolean @default(true)
description String?
account LoyaltyAccount @relation(fields: [accountId], references: [id])
@@schema("passenger")
}
model WalletAccount {
@@ -567,6 +656,8 @@ model WalletAccount {
passenger Passenger @relation(fields: [passengerId], references: [id])
ledger WalletLedgerEntry[]
@@index([passengerId])
@@schema("passenger")
}
model WalletLedgerEntry {
@@ -579,6 +670,8 @@ model WalletLedgerEntry {
relatedBookingId String?
createdAt DateTime @default(now())
wallet WalletAccount @relation(fields: [walletId], references: [id])
@@schema("passenger")
}
model Notification {
@@ -592,6 +685,8 @@ model Notification {
metadata Json?
createdAt DateTime @default(now())
passenger Passenger @relation(fields: [passengerId], references: [id])
@@schema("passenger")
}
model Promotion {
@@ -606,6 +701,8 @@ model Promotion {
deepLink String?
active Boolean @default(true)
createdAt DateTime @default(now())
@@schema("passenger")
}
model StationCrowdSignal {
@@ -618,6 +715,8 @@ model StationCrowdSignal {
observedAt DateTime?
updatedAt DateTime @updatedAt
station Station @relation(fields: [stationId], references: [id])
@@schema("passenger")
}
model WeatherAlert {
@@ -628,12 +727,16 @@ model WeatherAlert {
message String
validUntil DateTime
createdAt DateTime @default(now())
@@schema("passenger")
}
model MenuCategory {
id String @id @default(uuid())
name String
items MenuItem[]
@@schema("passenger")
}
model MenuItem {
@@ -647,6 +750,8 @@ model MenuItem {
availableUntil DateTime?
schedule TrainSchedule @relation(fields: [scheduleId], references: [id])
category MenuCategory @relation(fields: [categoryId], references: [id])
@@schema("passenger")
}
model FoodOrder {
@@ -660,6 +765,8 @@ model FoodOrder {
createdAt DateTime @default(now())
booking Booking @relation(fields: [bookingId], references: [id])
items FoodOrderItem[]
@@schema("passenger")
}
model FoodOrderItem {
@@ -671,6 +778,8 @@ model FoodOrderItem {
unitPriceMinor Int?
lineTotalMinor Int
order FoodOrder @relation(fields: [orderId], references: [id])
@@schema("passenger")
}
model FaqCategory {
@@ -678,6 +787,8 @@ model FaqCategory {
title String
iconKey String?
articles FaqArticle[]
@@schema("passenger")
}
model FaqArticle {
@@ -687,6 +798,8 @@ model FaqArticle {
answerMarkdown String
rank Int @default(0)
category FaqCategory @relation(fields: [categoryId], references: [id])
@@schema("passenger")
}
model SupportConversation {
@@ -696,6 +809,8 @@ model SupportConversation {
status SupportConversationStatus @default(OPEN)
createdAt DateTime @default(now())
messages SupportMessage[]
@@schema("passenger")
}
model SupportMessage {
@@ -706,6 +821,8 @@ model SupportMessage {
attachments Json?
createdAt DateTime @default(now())
conversation SupportConversation @relation(fields: [conversationId], references: [id])
@@schema("passenger")
}
model UserPreferences {
@@ -724,6 +841,8 @@ model UserPreferences {
darkMode Boolean @default(false)
language String @default("en")
user User @relation(fields: [userId], references: [id])
@@schema("passenger")
}
model Device {
@@ -735,6 +854,8 @@ model Device {
trusted Boolean @default(false)
lastSeenAt DateTime @default(now())
user User @relation(fields: [userId], references: [id])
@@schema("passenger")
}
model SavedRoute {
@@ -747,6 +868,8 @@ model SavedRoute {
tripCount Int @default(0)
createdAt DateTime @default(now())
passenger Passenger @relation(fields: [passengerId], references: [id])
@@schema("passenger")
}
model Journey {
@@ -757,6 +880,8 @@ model Journey {
currency String @default("ETB")
createdAt DateTime @default(now())
journeySegments JourneySegment[]
@@schema("passenger")
}
model JourneySegment {
@@ -770,6 +895,8 @@ model JourneySegment {
arrivalStationId String
journey Journey @relation(fields: [journeyId], references: [id])
schedule TrainSchedule @relation(fields: [scheduleId], references: [id])
@@schema("passenger")
}
model OtpCode {
@@ -783,6 +910,8 @@ model OtpCode {
verified Boolean @default(false)
createdAt DateTime @default(now())
@@index([email, phone])
@@schema("passenger")
}
model PasswordResetToken {
@@ -793,6 +922,8 @@ model PasswordResetToken {
used Boolean @default(false)
createdAt DateTime @default(now())
@@index([userId])
@@schema("passenger")
}
model Route {
@@ -806,6 +937,8 @@ model Route {
createdAt DateTime @default(now())
stops RouteStop[]
fareRules RouteFareRule[]
@@schema("passenger")
}
model RouteStop {
@@ -818,6 +951,8 @@ model RouteStop {
route Route @relation(fields: [routeId], references: [id], onDelete: Cascade)
@@unique([routeId, sequence])
@@index([routeId, stationId])
@@schema("passenger")
}
model RouteFareRule {
@@ -836,6 +971,8 @@ model RouteFareRule {
route Route @relation(fields: [routeId], references: [id], onDelete: Cascade)
seatClass SeatClass @relation(fields: [seatClassId], references: [id])
@@index([routeId, seatClassId])
@@schema("passenger")
}
model Agent {
@@ -850,6 +987,8 @@ model Agent {
bookings AgentBooking[]
shifts AgentShift[]
commissions AgentCommission[]
@@schema("passenger")
}
model AgentBooking {
@@ -863,6 +1002,8 @@ model AgentBooking {
createdAt DateTime @default(now())
agent Agent @relation(fields: [agentId], references: [id])
booking Booking @relation(fields: [bookingId], references: [id])
@@schema("passenger")
}
model AgentShift {
@@ -876,6 +1017,8 @@ model AgentShift {
notes String?
agent Agent @relation(fields: [agentId], references: [id])
@@index([agentId, openedAt])
@@schema("passenger")
}
model AgentCommission {
@@ -888,6 +1031,8 @@ model AgentCommission {
createdAt DateTime @default(now())
agent Agent @relation(fields: [agentId], references: [id])
@@index([agentId, paidAt])
@@schema("passenger")
}
model BookingModification {
@@ -902,6 +1047,8 @@ model BookingModification {
createdAt DateTime @default(now())
booking Booking @relation(fields: [bookingId], references: [id])
@@index([bookingId])
@@schema("passenger")
}
model BookingCancellation {
@@ -915,6 +1062,8 @@ model BookingCancellation {
processedAt DateTime?
createdAt DateTime @default(now())
booking Booking @relation(fields: [bookingId], references: [id])
@@schema("passenger")
}
model GateValidationLog {
@@ -928,6 +1077,8 @@ model GateValidationLog {
ticket Ticket @relation(fields: [ticketId], references: [id])
@@index([ticketId])
@@index([validatorId])
@@schema("passenger")
}
model BaggageAllowance {
@@ -938,6 +1089,8 @@ model BaggageAllowance {
excessFeePerKg Int
currency String @default("ETB")
createdAt DateTime @default(now())
@@schema("passenger")
}
model BaggageBooking {
@@ -950,6 +1103,8 @@ model BaggageBooking {
createdAt DateTime @default(now())
booking Booking @relation(fields: [bookingId], references: [id])
@@index([bookingId])
@@schema("passenger")
}
model AuditLog {
@@ -966,6 +1121,8 @@ model AuditLog {
user User? @relation(fields: [userId], references: [id])
@@index([userId, createdAt])
@@index([entityType, entityId])
@@schema("passenger")
}
model NotificationTemplate {
@@ -976,6 +1133,8 @@ model NotificationTemplate {
bodyTemplate String
active Boolean @default(true)
createdAt DateTime @default(now())
@@schema("passenger")
}
model SeatBlock {
@@ -988,6 +1147,8 @@ model SeatBlock {
unblockAt DateTime?
seat Seat @relation(fields: [seatId], references: [id])
@@index([seatId])
@@schema("passenger")
}
model OperationalReport {
@@ -999,6 +1160,8 @@ model OperationalReport {
generatedBy String?
createdAt DateTime @default(now())
@@index([reportType, dateFrom])
@@schema("passenger")
}
model FraudRule {
@@ -1009,6 +1172,8 @@ model FraudRule {
config Json?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@schema("passenger")
}
model FraudAlert {
@@ -1023,6 +1188,8 @@ model FraudAlert {
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId, createdAt])
@@index([acknowledged])
@@schema("passenger")
}
model CurrencyExchangeRate {
@@ -1035,6 +1202,8 @@ model CurrencyExchangeRate {
createdAt DateTime @default(now())
@@unique([fromCurrency, toCurrency, effectiveDate])
@@index([fromCurrency, toCurrency])
@@schema("passenger")
}
model VerifaydaVerification {
@@ -1049,4 +1218,6 @@ model VerifaydaVerification {
createdAt DateTime @default(now())
@@index([nationalId])
@@index([bookingId])
@@schema("passenger")
}