Created
May 7, 2024 09:47
-
-
Save suryaelidanto/5ed566c79066830fa370b645ad02d0b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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" | |
} | |
datasource db { | |
provider = "mysql" | |
relationMode = "prisma" | |
url = env("DATABASE_URL") | |
} | |
// your beautiful schema goes below : | |
model User { | |
id String @id @unique @default(uuid()) | |
name String | |
email String @unique | |
phone String @unique | |
password String | |
store Store? @relation(fields: [storeId], references: [id]) | |
storeId String? | |
role Role? @relation(fields: [roleId], references: [id]) | |
roleId String | |
profile Profile? | |
biteshipTrackingLimits BiteshipTrackingLimit[] | |
carts Cart[] | |
cartItems CartItem[] | |
invoices Invoice[] | |
payments Payment[] | |
withdraws Withdraw[] | |
verify Verify[] | |
isVerify Boolean | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([storeId]) | |
@@index([roleId]) | |
@@map("users") | |
} | |
model AttachmentAdmin { | |
id String @id @unique @default(uuid()) | |
attachment String | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
withdraw Withdraw? @relation(fields: [withdrawId], references: [id]) | |
withdrawId String | |
@@index([withdrawId]) | |
@@map("attachments_admin") | |
} | |
model Withdraw { | |
id String @id @unique @default(uuid()) | |
amount Float | |
status String | |
store Store? @relation(fields: [storeId], references: [id]) | |
storeId String | |
bankAccount BankAccount? @relation(fields: [bankId], references: [id]) | |
bankId String | |
approvedBy User? @relation(fields: [approvedById], references: [id]) | |
approvedById String | |
attachmentAdmin AttachmentAdmin[] | |
adminDecline AdminDecline[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([storeId]) | |
@@index([bankId]) | |
@@index([approvedById]) | |
@@map("withdraws") | |
} | |
model Role { | |
id String @id @unique @default(uuid()) | |
name String | |
users User[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@map("roles") | |
} | |
model Profile { | |
id String @id @unique @default(uuid()) | |
user User? @relation(fields: [userId], references: [id]) | |
userId String @unique | |
locations Location[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([userId]) | |
@@map("profiles") | |
} | |
model Store { | |
id String @id @unique @default(uuid()) | |
name String | |
credit Int @default(0) | |
slogan String? | |
description String | |
domain String | |
logoAttachment String? | |
bannerAttachment String? | |
users User[] | |
storesDecorations StoreDecoration[] | |
operationHours OperationHour[] | |
messageTemplates MessageTemplate[] | |
locations Location[] | |
products Product[] | |
carts Cart[] | |
bankAccounts BankAccount[] | |
withdraws Withdraw[] | |
adminDecline AdminDecline[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@map("stores") | |
} | |
model Decoration { | |
id String @id @unique @default(uuid()) | |
type String | |
storesDecorations StoreDecoration[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@map("decorations") | |
} | |
model StoreDecoration { | |
id String @id @unique @default(uuid()) | |
store Store? @relation(fields: [storeId], references: [id]) | |
storeId String | |
decoration Decoration? @relation(fields: [decorationId], references: [id]) | |
decorationId String | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([storeId]) | |
@@index([decorationId]) | |
@@map("stores_decorations") | |
} | |
model OperationHour { | |
id String @id @unique @default(uuid()) | |
day String | |
openAt DateTime | |
closeAt DateTime | |
isOff Boolean | |
store Store? @relation(fields: [storeId], references: [id]) | |
storeId String | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([storeId]) | |
@@map("operation_hours") | |
} | |
model MessageTemplate { | |
id String @id @unique @default(uuid()) | |
name String | |
content String | |
store Store? @relation(fields: [storeId], references: [id]) | |
storeId String | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([storeId]) | |
@@map("message_templates") | |
} | |
model Location { | |
id String @id @unique @default(uuid()) | |
name String | |
address String | |
addressNote String? | |
latitude String | |
longtitude String | |
postalCode String? | |
cityDistrict String | |
isMainLocation Boolean? @default(false) | |
store Store? @relation(fields: [storeId], references: [id]) | |
storeId String | |
profile Profile? @relation(fields: [profileId], references: [id]) | |
profileId String | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([storeId]) | |
@@index([profileId]) | |
@@map("locations") | |
} | |
model Product { | |
id String @id @unique @default(uuid()) | |
name String | |
description String | |
minimumOrder Int | |
length Float | |
width Float | |
height Float | |
slug String @unique | |
isActive Boolean @default(true) | |
store Store? @relation(fields: [storeId], references: [id]) | |
storeId String | |
category Category? @relation(fields: [categoryId], references: [id]) | |
categoryId String | |
attachments ProductAttachment[] | |
variants Variant[] | |
cartItems CartItem[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([storeId]) | |
@@index([categoryId]) | |
@@map("products") | |
} | |
model Variant { | |
id String @id @unique @default(uuid()) | |
name String | |
isActive Boolean | |
product Product @relation(fields: [productId], references: [id], onDelete: Cascade, onUpdate: Cascade) | |
productId String | |
variantOptions VariantOption[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([productId]) | |
@@map("variants") | |
} | |
model VariantOption { | |
id String @id @unique @default(uuid()) | |
name String | |
variant Variant? @relation(fields: [variantId], references: [id], onDelete: Cascade, onUpdate: Cascade) | |
variantId String | |
cartItems CartItem[] | |
variantOptionValues VariantOptionValue[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([variantId]) | |
@@map("variant_options") | |
} | |
model VariantOptionValue { | |
id String @id @unique @default(uuid()) | |
name String | |
sku String | |
weight Float | |
stock Int | |
price Float | |
variantOption VariantOption? @relation(fields: [variantOptionId], references: [id], onDelete: Cascade, onUpdate: Cascade) | |
variantOptionId String | |
isActive Boolean @default(true) | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([variantOptionId]) | |
@@map("variant_option_values") | |
} | |
model Category { | |
id String @id @unique @default(uuid()) | |
name String | |
parentId String? | |
products Product[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@map("categories") | |
} | |
model Cart { | |
id String @id @unique @default(uuid()) | |
price Float | |
discount Float | |
user User? @relation(fields: [userId], references: [id]) | |
userId String? | |
store Store? @relation(fields: [storeId], references: [id]) | |
storeId String | |
cartItems CartItem[] | |
invoices Invoice[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([userId]) | |
@@index([storeId]) | |
@@map("carts") | |
} | |
model CartItem { | |
id String @id @unique @default(uuid()) | |
qty Int | |
price Float | |
variantOption VariantOption? @relation(fields: [variantOptionId], references: [id], onDelete: Cascade, onUpdate: Cascade) | |
variantOptionId String | |
cart Cart? @relation(fields: [cartId], references: [id]) | |
cartId String | |
user User? @relation(fields: [userId], references: [id]) | |
userId String? | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
product Product? @relation(fields: [productId], references: [id]) | |
productId String? | |
@@index([variantOptionId]) | |
@@index([cartId]) | |
@@index([userId]) | |
@@index([productId]) | |
@@map("cart_items") | |
} | |
model Invoice { | |
id String @id @unique @default(uuid()) | |
price Float | |
discount Float | |
status String | |
receiverLongitude String | |
receiverLatitude String | |
receiverDistrict String | |
receiverPhone String | |
receiverAddress String | |
receiverName String | |
receiverEmail String | |
receiverPostalCode String | |
receiverAddressNote String? | |
invoiceNumber String | |
waybill String | |
mootaTransactionId String | |
confirmationPayment ConfirmationPayment? | |
cart Cart? @relation(fields: [cartId], references: [id]) | |
cartId String | |
courier Courier? @relation(fields: [courierId], references: [id]) | |
courierId String | |
user User? @relation(fields: [userId], references: [id]) | |
userId String? | |
payment Payment? @relation(fields: [paymentId], references: [id]) | |
paymentId String | |
biteshipTrackinglimits BiteshipTrackingLimit? | |
invoiceHistories InvoiceHistory[] | |
refund Refund[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([cartId]) | |
@@index([courierId]) | |
@@index([userId]) | |
@@index([paymentId]) | |
@@map("invoices") | |
} | |
model Payment { | |
id String @id @unique @default(uuid()) | |
bank String | |
amount Float | |
accountName String | |
accountNumber String | |
status String | |
user User? @relation(fields: [userId], references: [id]) | |
userId String? | |
invoices Invoice[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([userId]) | |
@@map("payments") | |
} | |
model Courier { | |
id String @id @unique @default(uuid()) | |
availableForCashOnDelivery Boolean? | |
availableForProofOfDelivery Boolean? | |
availableForInstantWaybillId Boolean? | |
courierType String | |
courierInsurance String? | |
courierName String | |
courierCode String | |
courierServiceName String | |
courierServiceCode String | |
tier String | |
description String | |
serviceType String | |
shippingType String | |
shipmentDurationRange String | |
shipmentDurationUnit String | |
price Float | |
orderId String | |
trackingId String | |
deliveryDate String | |
deliveryTime String | |
invoices Invoice[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@map("couriers") | |
} | |
model InvoiceHistory { | |
id String @id @unique @default(uuid()) | |
status String | |
invoice Invoice? @relation(fields: [invoiceId], references: [id]) | |
invoiceId String | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([invoiceId]) | |
@@map("invoice_histories") | |
} | |
model BankAccount { | |
id String @id @unique @default(uuid()) | |
bank String | |
accountName String | |
accountNumber String | |
store Store? @relation(fields: [storeId], references: [id]) | |
storeId String | |
withdraws Withdraw[] | |
adminDecline AdminDecline[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([storeId]) | |
@@map("bank_accounts") | |
} | |
model ProductAttachment { | |
id String @id @unique @default(uuid()) | |
url String | |
product Product? @relation(fields: [productId], references: [id], onDelete: Cascade, onUpdate: Cascade) | |
productId String | |
isMain Boolean @default(false) | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([productId]) | |
@@map("product_attachments") | |
} | |
model ConfirmationPayment { | |
id String @id @unique @default(uuid()) | |
amount Float | |
attachment String | |
invoice Invoice? @relation(fields: [invoiceId], references: [id]) | |
invoiceId String @unique | |
bank String | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([invoiceId]) | |
@@map("confirmation_payments") | |
} | |
model BiteshipTrackingLimit { | |
id String @id @unique @default(uuid()) | |
user User? @relation(fields: [userId], references: [id]) | |
userId String | |
invoice Invoice? @relation(fields: [invoiceId], references: [id]) | |
invoiceId String @unique | |
nextAccessTime DateTime | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([userId]) | |
@@index([invoiceId]) | |
@@map("biteship_tracking_limits") | |
} | |
model AdminDecline { | |
id String @id @unique @default(uuid()) | |
reason String | |
store Store? @relation(fields: [storeId], references: [id]) | |
storeId String | |
withdraw Withdraw? @relation(fields: [withdrawId], references: [id]) | |
withdrawId String | |
bankAccount BankAccount? @relation(fields: [bankAccountId], references: [id]) | |
bankAccountId String @unique | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([storeId]) | |
@@index([bankAccountId]) | |
@@index([withdrawId]) | |
@@map("admin_decline") | |
} | |
model Refund { | |
id String @id @unique @default(uuid()) | |
amount Float | |
status String | |
attachment String | |
invoice Invoice? @relation(fields: [invoiceId], references: [id]) | |
invoiceId String @unique | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([invoiceId]) | |
@@map("refund") | |
} | |
model Verify { | |
id String @id @unique @default(uuid()) | |
token String | |
user User? @relation(fields: [userId], references: [id]) | |
userId String @unique | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @default(now()) | |
@@index([userId]) | |
@@map("verify") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment