141 lines
3.2 KiB
Plaintext
141 lines
3.2 KiB
Plaintext
// 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"
|
|
output = "../generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
enum MerchantUserRole {
|
|
ADMIN
|
|
MANAGER
|
|
TECHNICAL
|
|
VIEWER
|
|
}
|
|
|
|
enum Currency {
|
|
XOF
|
|
XAF
|
|
EURO
|
|
DOLLARS
|
|
}
|
|
|
|
enum Periodicity {
|
|
Daily
|
|
Weekly
|
|
Monthly
|
|
OneTime
|
|
}
|
|
|
|
model MerchantUser {
|
|
id Int @id @default(autoincrement())
|
|
userId String // ID from external user service
|
|
merchantPartnerId Int
|
|
role MerchantUserRole
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
merchantPartner MerchantPartner @relation(fields: [merchantPartnerId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, merchantPartnerId])
|
|
@@map("merchant_users")
|
|
}
|
|
|
|
model MerchantPartner {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
logo String?
|
|
description String?
|
|
adresse String?
|
|
phone String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
configs Config[]
|
|
services Service[]
|
|
technicalContacts TechnicalContact[]
|
|
merchantUsers MerchantUser[]
|
|
@@map("merchant_partners")
|
|
}
|
|
|
|
|
|
|
|
model Config {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
value String
|
|
merchantPartnerId Int
|
|
operatorId Int?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
merchantPartner MerchantPartner @relation(fields: [merchantPartnerId], references: [id], onDelete: Cascade)
|
|
operator Operator? @relation(fields: [operatorId], references: [id])
|
|
|
|
@@map("configs")
|
|
}
|
|
|
|
|
|
|
|
|
|
model Service {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
description String?
|
|
merchantPartnerId Int
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
merchantPartner MerchantPartner @relation(fields: [merchantPartnerId], references: [id], onDelete: Cascade)
|
|
plans Plan[]
|
|
|
|
@@map("services")
|
|
}
|
|
|
|
model Plan {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
type Periodicity
|
|
amount Float
|
|
tax Float
|
|
currency Currency
|
|
periodicity Periodicity
|
|
serviceId Int
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("pricings")
|
|
}
|
|
|
|
model TechnicalContact {
|
|
id Int @id @default(autoincrement())
|
|
firstName String
|
|
lastName String
|
|
phone String
|
|
email String
|
|
merchantPartnerId Int
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
merchantPartner MerchantPartner @relation(fields: [merchantPartnerId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("technical_contacts")
|
|
}
|
|
|
|
model Operator {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
configs Config[]
|
|
|
|
@@map("operators")
|
|
}
|