141 lines
3.0 KiB
Plaintext
141 lines
3.0 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL") // ← AJOUTEZ CETTE LIGNE
|
|
}
|
|
|
|
|
|
|
|
|
|
model Transaction {
|
|
id Int @id @default(autoincrement())
|
|
date DateTime @default(now())
|
|
amount Float
|
|
tax Float
|
|
status TransactionStatus
|
|
merchantPartnerId Int
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
reversementRequests ReversementRequest[]
|
|
|
|
@@map("transactions")
|
|
}
|
|
|
|
enum TransactionStatus {
|
|
SUCCESS
|
|
FAILED
|
|
PENDING
|
|
}
|
|
|
|
enum SubscriptionStatus {
|
|
ACTIVE
|
|
TRIAL
|
|
PENDING
|
|
SUSPENDED
|
|
EXPIRED
|
|
CANCELLED
|
|
}
|
|
enum Periodicity {
|
|
Daily
|
|
Weekly
|
|
Monthly
|
|
OneTime
|
|
}
|
|
|
|
model Subscription {
|
|
id Int @id @default(autoincrement())
|
|
externalReference String?
|
|
periodicity Periodicity
|
|
startDate DateTime
|
|
endDate DateTime?
|
|
amount Float
|
|
currency String
|
|
token String
|
|
status SubscriptionStatus
|
|
nextPaymentDate DateTime
|
|
suspendedAt DateTime?
|
|
merchantPartnerId Int
|
|
customerId Int
|
|
planId Int
|
|
serviceId Int
|
|
failureCount Int?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
metadata Json?
|
|
|
|
@@map("subscriptions")
|
|
}
|
|
|
|
model ReversementRequest {
|
|
id Int @id @default(autoincrement())
|
|
externalReference String?
|
|
startDate DateTime
|
|
endDate DateTime
|
|
amount Float
|
|
tax Float
|
|
status TransactionStatus
|
|
transactionId Int
|
|
paymentId Int?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
metadata Json?
|
|
|
|
transaction Transaction @relation(fields: [transactionId], references: [id], onDelete: Cascade)
|
|
payment Payment? @relation(fields: [paymentId], references: [id])
|
|
|
|
@@map("reversement_requests")
|
|
}
|
|
|
|
model Payment {
|
|
id Int @id @default(autoincrement())
|
|
externalReference String?
|
|
reference String?
|
|
type PaymentType
|
|
status TransactionStatus
|
|
merchantPartnerId Int
|
|
failureReason String?
|
|
amount Float?
|
|
currency String
|
|
completedAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
customerId Int
|
|
subscriptionId Int?
|
|
metadata Json?
|
|
link String?
|
|
|
|
reversementRequests ReversementRequest[]
|
|
|
|
@@map("payments")
|
|
}
|
|
|
|
enum PaymentType {
|
|
MM
|
|
BANK
|
|
CHEQUE
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
msisdn String @unique
|
|
userToken String @unique
|
|
userAlias String
|
|
operatorId String
|
|
merchantPartnerId Int
|
|
country String
|
|
metadata Json?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
|