247 lines
9.1 KiB
Plaintext
247 lines
9.1 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
firstName String @map("first_name") @db.VarChar(100)
|
|
lastName String @map("last_name") @db.VarChar(100)
|
|
email String @unique @db.VarChar(150)
|
|
mobile String? @unique @db.VarChar(15)
|
|
role String @default("User_PetOwner") @db.VarChar(30)
|
|
walletBalance Decimal @default(0.00) @map("wallet_balance") @db.Decimal(15, 2)
|
|
charityDonationTotal Decimal @default(0.00) @map("charity_donation_total") @db.Decimal(15, 2)
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz()
|
|
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamptz()
|
|
|
|
addresses UserAddress[]
|
|
walletTransactions WalletTransaction[]
|
|
pets Pet[]
|
|
orders Order[]
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model UserAddress {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
userId String @map("user_id") @db.Uuid
|
|
title String @db.VarChar(100)
|
|
receptorName String @map("receptor_name") @db.VarChar(150)
|
|
phone String @db.VarChar(15)
|
|
province String @db.VarChar(100)
|
|
city String @db.VarChar(100)
|
|
detail String @db.Text
|
|
zipCode String @map("zip_code") @db.VarChar(10)
|
|
isDefault Boolean @default(false) @map("is_default")
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz()
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([userId])
|
|
@@map("user_addresses")
|
|
}
|
|
|
|
model WalletTransaction {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
userId String @map("user_id") @db.Uuid
|
|
amount Decimal @db.Decimal(15, 2)
|
|
type String @db.VarChar(20) // deposit, withdrawal
|
|
status String @db.VarChar(20) // pending, completed, failed
|
|
transactionReference String? @unique @map("transaction_reference") @db.VarChar(100)
|
|
description String? @db.Text
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz()
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("wallet_transactions")
|
|
}
|
|
|
|
model Product {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
artNo String @unique @map("art_no") @db.VarChar(20)
|
|
name String @db.VarChar(200)
|
|
scientificTagline String? @map("scientific_tagline") @db.VarChar(250)
|
|
description String @db.Text
|
|
shortDescription String? @map("short_description") @db.Text
|
|
category String @db.VarChar(100)
|
|
categorySlug String @map("category_slug") @db.VarChar(100)
|
|
priceValue Decimal @map("price_value") @db.Decimal(15, 2)
|
|
priceDisplay String @map("price_display") @db.VarChar(50)
|
|
unit String @db.VarChar(50)
|
|
packageSize Decimal @map("package_size") @db.Decimal(10, 2)
|
|
dosageLogic String? @map("dosage_logic") @db.Text
|
|
suitableFor String @map("suitable_for") @db.VarChar(15) // سگ, گربه, هر دو
|
|
imageUrl String @map("image_url") @db.Text
|
|
metaTitle String? @map("meta_title") @db.VarChar(200)
|
|
metaDescription String? @map("meta_description") @db.Text
|
|
canonicalUrl String? @map("canonical_url") @db.Text
|
|
keywords String? @db.Text
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz()
|
|
|
|
ingredients ProductIngredient[]
|
|
symptoms ProductSymptom[]
|
|
reminders Reminder[]
|
|
orderItems OrderItem[]
|
|
|
|
@@index([categorySlug])
|
|
@@index([suitableFor])
|
|
@@map("products")
|
|
}
|
|
|
|
model ProductIngredient {
|
|
productId String @map("product_id") @db.Uuid
|
|
ingredient String @db.VarChar(150)
|
|
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
|
|
|
@@id([productId, ingredient])
|
|
@@map("product_ingredients")
|
|
}
|
|
|
|
model ProductSymptom {
|
|
productId String @map("product_id") @db.Uuid
|
|
symptom String @db.VarChar(150)
|
|
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
|
|
|
@@id([productId, symptom])
|
|
@@map("product_symptoms")
|
|
}
|
|
|
|
model Pet {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
userId String @map("user_id") @db.Uuid
|
|
name String @db.VarChar(100)
|
|
type String @db.VarChar(10) // سگ, گربه
|
|
breed String @db.VarChar(100)
|
|
age Int
|
|
weight Decimal @db.Decimal(5, 2)
|
|
activityLevel String @map("activity_level") @db.VarChar(15) // کم, متوسط, زیاد
|
|
imageUrl String? @map("image_url") @db.Text
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz()
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
medicalConditions PetMedicalCondition[]
|
|
reminders Reminder[]
|
|
healthLogs HealthLog[]
|
|
|
|
@@map("pets")
|
|
}
|
|
|
|
model PetMedicalCondition {
|
|
petId String @map("pet_id") @db.Uuid
|
|
condition String @db.VarChar(150)
|
|
pet Pet @relation(fields: [petId], references: [id], onDelete: Cascade)
|
|
|
|
@@id([petId, condition])
|
|
@@map("pet_medical_conditions")
|
|
}
|
|
|
|
model Reminder {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
petId String @map("pet_id") @db.Uuid
|
|
productId String? @map("product_id") @db.Uuid
|
|
title String @db.VarChar(150)
|
|
time String @db.VarChar(5) // 08:30
|
|
frequency String @db.VarChar(20) // روزانه, هفتگی
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz()
|
|
|
|
pet Pet @relation(fields: [petId], references: [id], onDelete: Cascade)
|
|
product Product? @relation(fields: [productId], references: [id], onDelete: SetNull)
|
|
completions ReminderCompletion[]
|
|
|
|
@@index([petId])
|
|
@@map("reminders")
|
|
}
|
|
|
|
model ReminderCompletion {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
reminderId String @map("reminder_id") @db.Uuid
|
|
completedDate DateTime @map("completed_date") @db.Date
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz()
|
|
|
|
reminder Reminder @relation(fields: [reminderId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([reminderId, completedDate])
|
|
@@index([reminderId, completedDate])
|
|
@@map("reminder_completions")
|
|
}
|
|
|
|
model HealthLog {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
petId String @map("pet_id") @db.Uuid
|
|
appetite String @db.VarChar(15)
|
|
energy String @db.VarChar(15)
|
|
digestion String @db.VarChar(15)
|
|
note String? @db.Text
|
|
loggedDate DateTime @default(now()) @map("logged_date") @db.Date
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz()
|
|
|
|
pet Pet @relation(fields: [petId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("health_logs")
|
|
}
|
|
|
|
model Coupon {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
code String @unique @db.VarChar(50)
|
|
discountValue Decimal @map("discount_value") @db.Decimal(15, 2)
|
|
isActive Boolean @default(true) @map("is_active")
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz()
|
|
|
|
orders Order[]
|
|
|
|
@@map("coupons")
|
|
}
|
|
|
|
model Order {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
userId String @map("user_id") @db.Uuid
|
|
couponId String? @map("coupon_id") @db.Uuid
|
|
totalAmount Decimal @map("total_amount") @db.Decimal(15, 2)
|
|
charityDonation Decimal @default(0.00) @map("charity_donation") @db.Decimal(15, 2)
|
|
status String @default("processing") @db.VarChar(30) // processing, shipped, delivered
|
|
trackingNumber String? @unique @map("tracking_number") @db.VarChar(100)
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz()
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
coupon Coupon? @relation(fields: [couponId], references: [id])
|
|
orderItems OrderItem[]
|
|
|
|
@@map("orders")
|
|
}
|
|
|
|
model OrderItem {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
orderId String @map("order_id") @db.Uuid
|
|
productId String? @map("product_id") @db.Uuid
|
|
quantity Int
|
|
doseQty Decimal? @map("dose_qty") @db.Decimal(10, 2)
|
|
doseUnit String? @map("dose_unit") @db.VarChar(50)
|
|
|
|
order Order @relation(fields: [orderId], references: [id], onDelete: Cascade)
|
|
product Product? @relation(fields: [productId], references: [id], onDelete: SetNull)
|
|
|
|
@@map("order_items")
|
|
}
|
|
|
|
model UiText {
|
|
key String @id @db.VarChar(100)
|
|
value String @db.Text
|
|
|
|
@@map("ui_texts")
|
|
}
|
|
|
|
model ScientificTerm {
|
|
key String @id @db.VarChar(100)
|
|
term String @db.VarChar(150)
|
|
definition String @db.Text
|
|
wikiId String @map("wiki_id") @db.VarChar(50)
|
|
|
|
@@map("scientific_terms")
|
|
}
|
|
|