584 lines
19 KiB
Plaintext
584 lines
19 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
binaryTargets = ["linux-musl-openssl-3.0.x", "debian-openssl-3.0.x"]
|
|
}
|
|
|
|
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?
|
|
miniAppSettings Json?
|
|
config Json?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
bookings Booking[]
|
|
customerUsers CustomerUser[]
|
|
tags Tag[]
|
|
trustContents TrustContent[]
|
|
templateInstallations BrandTemplateInstallation[]
|
|
fieldDefinitions BrandFieldDefinition[]
|
|
offerings Offering[]
|
|
inquiryForms InquiryForm[]
|
|
inquirySubmissions InquirySubmission[]
|
|
capabilityInstallations CapabilityInstallation[]
|
|
capabilityAuditLogs CapabilityAuditLog[]
|
|
adminMemberships BrandMembership[]
|
|
releases BrandRelease[]
|
|
miniAppReleases MiniAppReleaseTask[]
|
|
bootstrapImports TemplateBootstrapImport[]
|
|
}
|
|
|
|
model BrandRelease {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
version Int
|
|
status String @default("published")
|
|
snapshot Json
|
|
actorId String
|
|
note String?
|
|
createdAt DateTime @default(now())
|
|
revokedAt DateTime?
|
|
revokedBy String?
|
|
miniAppReleases MiniAppReleaseTask[]
|
|
|
|
@@unique([brandId, version])
|
|
@@index([brandId, status, createdAt])
|
|
}
|
|
|
|
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])
|
|
}
|
|
|
|
enum MiniAppReleaseStatus {
|
|
built
|
|
uploaded
|
|
under_review
|
|
rejected
|
|
approved
|
|
published
|
|
failed
|
|
}
|
|
|
|
model MiniAppReleaseTask {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
releaseId String?
|
|
release BrandRelease? @relation(fields: [releaseId], references: [id], onDelete: SetNull)
|
|
version Int
|
|
status MiniAppReleaseStatus @default(built)
|
|
artifactPath String?
|
|
buildLogs Json?
|
|
buildStatus MiniAppBuildStatus @default(idle)
|
|
uploadStatus MiniAppUploadStatus @default(idle)
|
|
reviewStatus MiniAppReviewStatus @default(not_submitted)
|
|
actorId String
|
|
error String?
|
|
weappUploadId String?
|
|
audit Json?
|
|
attempts MiniAppReleaseAttempt[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([brandId, version])
|
|
@@index([brandId, createdAt])
|
|
}
|
|
|
|
enum MiniAppBuildStatus {
|
|
idle
|
|
building
|
|
success
|
|
failed
|
|
}
|
|
|
|
enum MiniAppUploadStatus {
|
|
idle
|
|
uploading
|
|
uploaded
|
|
failed
|
|
timed_out
|
|
}
|
|
|
|
enum MiniAppReviewStatus {
|
|
not_submitted
|
|
under_review
|
|
approved
|
|
rejected
|
|
}
|
|
|
|
enum MiniAppAttemptPhase {
|
|
build
|
|
upload
|
|
}
|
|
|
|
enum MiniAppAttemptStatus {
|
|
running
|
|
succeeded
|
|
failed
|
|
timed_out
|
|
}
|
|
|
|
model MiniAppReleaseAttempt {
|
|
id String @id @default(uuid())
|
|
taskId String
|
|
task MiniAppReleaseTask @relation(fields: [taskId], references: [id], onDelete: Cascade)
|
|
brandId String
|
|
actorId String
|
|
phase MiniAppAttemptPhase
|
|
attempt Int
|
|
status MiniAppAttemptStatus @default(running)
|
|
leaseToken String @unique
|
|
leaseExpiresAt DateTime
|
|
startedAt DateTime @default(now())
|
|
heartbeatAt DateTime @default(now())
|
|
finishedAt DateTime?
|
|
artifactPath String?
|
|
externalId String?
|
|
error String?
|
|
logs Json?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([taskId, phase, attempt])
|
|
@@index([brandId, taskId, phase, status])
|
|
}
|
|
|
|
enum PlatformTemplateRole {
|
|
none
|
|
template_admin
|
|
}
|
|
|
|
enum TemplatePackageVersionStatus {
|
|
imported
|
|
published
|
|
retired
|
|
disabled
|
|
}
|
|
|
|
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")
|
|
visualTemplateKey String?
|
|
templatePackageVersionId String?
|
|
templatePackageVersion TemplatePackageVersion? @relation("BrandTemplateInstallationPackageVersion", fields: [templatePackageVersionId], references: [id], onDelete: SetNull)
|
|
contentChecksum String?
|
|
configSnapshot Json
|
|
previousSnapshots Json @default("[]")
|
|
installedAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([brandId, templateKey])
|
|
@@index([brandId])
|
|
@@index([templatePackageVersionId])
|
|
}
|
|
|
|
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")
|
|
platformTemplateRole PlatformTemplateRole @default(none)
|
|
isEnabled Boolean @default(true)
|
|
mustChangePassword Boolean @default(false)
|
|
lastLoginAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
memberships BrandMembership[]
|
|
importedTemplateVersions TemplatePackageVersion[] @relation("TemplatePackageImportedBy")
|
|
templateAuditLogs TemplatePackageAuditLog[] @relation("TemplatePackageAuditActor")
|
|
}
|
|
|
|
model TemplatePackage {
|
|
id String @id @default(uuid())
|
|
packageKey String @unique
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
versions TemplatePackageVersion[]
|
|
}
|
|
|
|
model TemplatePackageVersion {
|
|
id String @id @default(uuid())
|
|
templatePackageId String
|
|
templatePackage TemplatePackage @relation(fields: [templatePackageId], references: [id], onDelete: Cascade)
|
|
packageKey String
|
|
version String
|
|
displayName String
|
|
visualTemplateKey String?
|
|
status TemplatePackageVersionStatus @default(imported)
|
|
manifestSnapshot Json
|
|
validationReport Json
|
|
contentChecksum String
|
|
archiveChecksum String
|
|
artifactPath String
|
|
importedById String
|
|
importedBy AdminUser @relation("TemplatePackageImportedBy", fields: [importedById], references: [id], onDelete: Restrict)
|
|
auditLogs TemplatePackageAuditLog[]
|
|
installations BrandTemplateInstallation[] @relation("BrandTemplateInstallationPackageVersion")
|
|
bootstrapImports TemplateBootstrapImport[]
|
|
importedAt DateTime @default(now())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([templatePackageId, version])
|
|
@@index([packageKey, status])
|
|
@@index([importedById, importedAt])
|
|
}
|
|
|
|
model TemplateBootstrapImport {
|
|
id String @id @default(uuid())
|
|
brandId String
|
|
brand BrandProfile @relation(fields: [brandId], references: [id], onDelete: Cascade)
|
|
templatePackageVersionId String
|
|
templatePackageVersion TemplatePackageVersion @relation(fields: [templatePackageVersionId], references: [id], onDelete: Restrict)
|
|
packageKey String
|
|
packageVersion String
|
|
contentChecksum String
|
|
actorId String
|
|
strategy String @default("missing_only")
|
|
status String
|
|
result Json?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([brandId, createdAt])
|
|
@@index([templatePackageVersionId, createdAt])
|
|
@@index([actorId, createdAt])
|
|
}
|
|
|
|
model TemplatePackageAuditLog {
|
|
id String @id @default(uuid())
|
|
templatePackageVersionId String
|
|
templatePackageVersion TemplatePackageVersion @relation(fields: [templatePackageVersionId], references: [id], onDelete: Cascade)
|
|
actorId String
|
|
actor AdminUser @relation("TemplatePackageAuditActor", fields: [actorId], references: [id], onDelete: Restrict)
|
|
action String
|
|
fromStatus TemplatePackageVersionStatus?
|
|
toStatus TemplatePackageVersionStatus?
|
|
requestId String?
|
|
metadata Json?
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([templatePackageVersionId, createdAt])
|
|
@@index([actorId, createdAt])
|
|
}
|
|
|
|
model TemplateOperationFailureEvent {
|
|
id String @id @default(uuid())
|
|
action String
|
|
resultCode String
|
|
requestId String?
|
|
actorId String?
|
|
brandId String?
|
|
packageKey String?
|
|
version String?
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([createdAt, action])
|
|
@@index([packageKey, createdAt])
|
|
}
|
|
|
|
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])
|
|
}
|