358 lines
11 KiB
Plaintext
358 lines
11 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
enum BookingStatus {
|
|
received
|
|
contacting
|
|
confirmed
|
|
completed
|
|
cancelled
|
|
}
|
|
|
|
enum BookingRequestType {
|
|
package
|
|
private_chef
|
|
inquiry
|
|
}
|
|
|
|
enum ContactPreference {
|
|
wechat
|
|
phone
|
|
none
|
|
}
|
|
|
|
enum FulfillmentType {
|
|
pickup
|
|
delivery
|
|
}
|
|
|
|
model BrandProfile {
|
|
id String @id @default(uuid())
|
|
slug String @unique @default("default-brand")
|
|
name String
|
|
templateKey String @default("food")
|
|
tagline String?
|
|
description String?
|
|
avatarUrl String?
|
|
coverUrl String?
|
|
hours String?
|
|
address String?
|
|
deliveryNote String?
|
|
contactPhone String?
|
|
contactWechat String?
|
|
config Json?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
bookings Booking[]
|
|
customerUsers CustomerUser[]
|
|
tags Tag[]
|
|
trustContents TrustContent[]
|
|
templateInstallations BrandTemplateInstallation[]
|
|
modules BrandModule[]
|
|
fieldDefinitions BrandFieldDefinition[]
|
|
offerings Offering[]
|
|
inquiryForms InquiryForm[]
|
|
inquirySubmissions InquirySubmission[]
|
|
capabilityInstallations CapabilityInstallation[]
|
|
capabilityAuditLogs CapabilityAuditLog[]
|
|
adminMemberships BrandMembership[]
|
|
}
|
|
|
|
model CapabilityInstallation {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
capabilityKey String
|
|
capabilityVersion String
|
|
status String @default("enabled")
|
|
config Json?
|
|
installedAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
@@unique([brandId, capabilityKey])
|
|
@@index([brandId, status])
|
|
}
|
|
|
|
model CapabilityAuditLog {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
capabilityKey String
|
|
actorId String
|
|
action String
|
|
fromStatus String?
|
|
toStatus String
|
|
config Json?
|
|
createdAt DateTime @default(now())
|
|
@@index([brandId, capabilityKey, createdAt])
|
|
}
|
|
|
|
model BrandTemplateInstallation {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
templateKey String
|
|
templateVersion String @default("1.0.0")
|
|
configSnapshot Json
|
|
previousSnapshots Json @default("[]")
|
|
installedAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
@@unique([brandId, templateKey])
|
|
@@index([brandId])
|
|
}
|
|
|
|
model BrandModule {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
type String
|
|
title String
|
|
isEnabled Boolean @default(true)
|
|
sortOrder Int @default(0)
|
|
source String @default("core")
|
|
config Json?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
@@index([brandId, isEnabled, sortOrder])
|
|
}
|
|
|
|
model BrandFieldDefinition {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
scope String
|
|
key String
|
|
label String
|
|
type String
|
|
required Boolean @default(false)
|
|
isVisible Boolean @default(true)
|
|
sortOrder Int @default(0)
|
|
source String @default("custom")
|
|
isOverridden Boolean @default(false)
|
|
options Json?
|
|
visibleWhen Json?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
@@unique([brandId, scope, key])
|
|
@@index([brandId, scope, sortOrder])
|
|
}
|
|
|
|
model Offering {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
kind String @default("service")
|
|
name String
|
|
summary String?
|
|
description String?
|
|
coverUrl String?
|
|
priceText String?
|
|
priceAmount Int?
|
|
isEnabled Boolean @default(true)
|
|
sortOrder Int @default(0)
|
|
config Json?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
inquiryForms InquiryForm[]
|
|
inquirySubmissions InquirySubmission[]
|
|
bookings Booking[]
|
|
bookingItems BookingItem[]
|
|
@@unique([brandId, name])
|
|
@@index([brandId, isEnabled, sortOrder])
|
|
}
|
|
|
|
model InquiryForm {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
offeringId String?
|
|
offering Offering? @relation(fields: [offeringId], references: [id], onDelete: SetNull)
|
|
name String
|
|
purpose String @default("inquiry")
|
|
targetType String @default("brand")
|
|
submissionAction String @default("create-inquiry")
|
|
version Int @default(1)
|
|
isEnabled Boolean @default(true)
|
|
fieldsSnapshot Json
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
submissions InquirySubmission[]
|
|
@@index([brandId, isEnabled])
|
|
}
|
|
|
|
model InquirySubmission {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
inquiryFormId String
|
|
offeringId String?
|
|
customerSubject String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
inquiryForm InquiryForm @relation(fields: [inquiryFormId], references: [id], onDelete: Restrict)
|
|
offering Offering? @relation(fields: [offeringId], references: [id], onDelete: SetNull)
|
|
formVersion Int
|
|
fieldsSnapshot Json
|
|
values Json
|
|
activeFields Json
|
|
status String @default("new")
|
|
adminNote String?
|
|
updatedAt DateTime @updatedAt
|
|
statusHistory InquirySubmissionStatusHistory[]
|
|
createdAt DateTime @default(now())
|
|
@@index([brandId, createdAt])
|
|
@@index([brandId, customerSubject, createdAt])
|
|
@@index([inquiryFormId, formVersion])
|
|
}
|
|
|
|
model InquirySubmissionStatusHistory {
|
|
id String @id @default(uuid())
|
|
submissionId String
|
|
submission InquirySubmission @relation(fields: [submissionId], references: [id], onDelete: Cascade)
|
|
fromStatus String?
|
|
toStatus String
|
|
adminNote String?
|
|
createdAt DateTime @default(now())
|
|
@@index([submissionId, createdAt])
|
|
}
|
|
|
|
model TrustContent {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
type String
|
|
title String
|
|
summary String?
|
|
content String
|
|
coverUrl String?
|
|
sortOrder Int @default(0)
|
|
isPublished Boolean @default(true)
|
|
config Json?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
@@index([brandId, type, sortOrder])
|
|
}
|
|
|
|
model CustomerUser {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id])
|
|
openid String
|
|
lastLoginAt DateTime @default(now())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
bookings Booking[]
|
|
@@unique([brandId, openid])
|
|
}
|
|
|
|
model Booking {
|
|
id String @id @default(uuid())
|
|
bookingNo String @unique
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id])
|
|
customerUserId String
|
|
customerUser CustomerUser @relation(fields: [customerUserId], references: [id])
|
|
requestType BookingRequestType
|
|
customerName String
|
|
phone String?
|
|
wechatId String?
|
|
contactPreference ContactPreference
|
|
fulfillmentType FulfillmentType?
|
|
offeringId String?
|
|
offering Offering? @relation(fields: [offeringId], references: [id], onDelete: SetNull)
|
|
requestedDate DateTime?
|
|
requestedTime String?
|
|
deliveryAddress String?
|
|
estimatedAmount Int?
|
|
extraData Json?
|
|
note String?
|
|
adminNote String?
|
|
status BookingStatus @default(received)
|
|
workflowKey String @default("booking.basic")
|
|
workflowVersion String @default("1.0.0")
|
|
currentState String @default("received")
|
|
isRead Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
items BookingItem[]
|
|
tags BookingTag[]
|
|
stateTransitions BookingStateTransition[]
|
|
@@index([brandId, status, createdAt])
|
|
@@index([customerUserId, createdAt])
|
|
}
|
|
|
|
model BookingStateTransition {
|
|
id String @id @default(uuid())
|
|
bookingId String
|
|
booking Booking @relation(fields: [bookingId], references: [id], onDelete: Cascade)
|
|
workflowKey String
|
|
workflowVersion String
|
|
fromState String?
|
|
toState String
|
|
actorRole String
|
|
createdAt DateTime @default(now())
|
|
@@index([bookingId, createdAt])
|
|
}
|
|
|
|
model BookingItem {
|
|
id String @id @default(uuid())
|
|
bookingId String
|
|
booking Booking @relation(fields: [bookingId], references: [id], onDelete: Cascade)
|
|
offeringId String?
|
|
offering Offering? @relation(fields: [offeringId], references: [id], onDelete: SetNull)
|
|
serviceNameSnapshot String
|
|
unitPriceSnapshot Int
|
|
quantity Int
|
|
subtotalSnapshot Int
|
|
}
|
|
|
|
model Tag {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id])
|
|
name String
|
|
isPreset Boolean @default(false)
|
|
isEnabled Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
bookings BookingTag[]
|
|
@@unique([brandId, name])
|
|
}
|
|
|
|
model AdminUser {
|
|
id String @id @default(uuid())
|
|
username String @unique
|
|
passwordHash String
|
|
displayName String
|
|
role String @default("admin")
|
|
isEnabled Boolean @default(true)
|
|
lastLoginAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
memberships BrandMembership[]
|
|
}
|
|
|
|
model BrandMembership {
|
|
id String @id @default(uuid())
|
|
adminUserId String
|
|
brandId String
|
|
role String @default("admin")
|
|
isEnabled Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
adminUser AdminUser @relation(fields: [adminUserId], references: [id], onDelete: Cascade)
|
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
@@unique([adminUserId, brandId])
|
|
@@index([brandId, isEnabled])
|
|
}
|
|
|
|
model BookingTag {
|
|
bookingId String
|
|
tagId String
|
|
booking Booking @relation(fields: [bookingId], references: [id], onDelete: Cascade)
|
|
tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
|
|
@@id([bookingId, tagId])
|
|
}
|