100 lines
3.8 KiB
Plaintext
100 lines
3.8 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "mysql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
enum Direction {
|
|
incoming
|
|
outgoing
|
|
system
|
|
}
|
|
|
|
model Customer {
|
|
id BigInt @id @default(autoincrement())
|
|
customerId String @unique @map("customer_id") @db.VarChar(256)
|
|
name String? @db.VarChar(128)
|
|
country String? @db.VarChar(64)
|
|
email String? @db.VarChar(128)
|
|
phone String? @db.VarChar(64)
|
|
company String? @db.VarChar(255)
|
|
registerTime DateTime? @map("register_time")
|
|
avatarUrl String? @map("avatar_url") @db.VarChar(512)
|
|
buyerTags String? @map("buyer_tags") @db.VarChar(255)
|
|
buyerFeatures String? @map("buyer_features") @db.VarChar(255)
|
|
bProductViews Int? @map("behavior_product_views")
|
|
bValidInquiries Int? @map("behavior_valid_inquiries")
|
|
bValidRfq Int? @map("behavior_valid_rfq")
|
|
bLoginDays Int? @map("behavior_login_days")
|
|
bSpamInquiries Int? @map("behavior_spam_inquiries")
|
|
bBlacklist Int? @map("behavior_blacklist")
|
|
bTopIndustry String? @map("behavior_top_industry") @db.VarChar(255)
|
|
recentProductsImages String? @map("recent_products_images") @db.Text
|
|
storeInquiryProduct String? @map("store_inquiry_product") @db.VarChar(512)
|
|
storeInquiryQty String? @map("store_inquiry_qty") @db.VarChar(32)
|
|
storeVisitProducts String? @map("store_visit_products") @db.Text
|
|
landline String? @map("landline") @db.VarChar(32)
|
|
businessType String? @map("business_type") @db.VarChar(128)
|
|
salesPlatform String? @map("sales_platform") @db.VarChar(255)
|
|
website String? @map("website") @db.VarChar(512)
|
|
inquiries Inquiry[]
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@index([country])
|
|
@@map("customers")
|
|
}
|
|
|
|
model Inquiry {
|
|
id BigInt @id @default(autoincrement())
|
|
inquiryId String @unique @map("inquiry_id") @db.VarChar(32)
|
|
customerId String? @map("customer_id") @db.VarChar(256)
|
|
manager String? @db.VarChar(128)
|
|
createTime DateTime @map("create_time")
|
|
updateTime DateTime @map("update_time")
|
|
status String? @db.VarChar(64)
|
|
msgPreview String? @map("msg_preview") @db.VarChar(512)
|
|
allInquiries String? @map("all_inquiries") @db.Text
|
|
isFlagged Boolean @default(false) @map("is_flagged")
|
|
messagesCount Int @default(0) @map("messages_count")
|
|
lastSendTime DateTime? @map("last_send_time")
|
|
hasFailedBatches Boolean @default(false) @map("has_failed_batches")
|
|
customer Customer? @relation(fields: [customerId], references: [customerId])
|
|
messages ChatMessage[]
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
@@index([customerId])
|
|
@@index([manager])
|
|
@@map("inquiries")
|
|
}
|
|
|
|
model ChatMessage {
|
|
id BigInt @id @default(autoincrement())
|
|
messageId String @unique @map("message_id") @db.VarChar(64)
|
|
inquiryId String @map("inquiry_id") @db.VarChar(32)
|
|
sender String? @db.VarChar(128)
|
|
direction Direction
|
|
sendTime DateTime @map("send_time")
|
|
content String @db.MediumText
|
|
translation String? @db.Text
|
|
inquiry Inquiry @relation(fields: [inquiryId], references: [inquiryId])
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
@@index([inquiryId, sendTime, messageId])
|
|
@@index([inquiryId])
|
|
@@map("chat_messages")
|
|
}
|
|
|
|
model User {
|
|
id BigInt @id @default(autoincrement())
|
|
username String @unique
|
|
passwordHash String @map("password_hash")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
@@map("users")
|
|
}
|