103 lines
2.6 KiB
Plaintext
103 lines
2.6 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
/// Категория изделий (игрушки, сувениры и т.д.)
|
|
model Category {
|
|
id String @id @default(cuid())
|
|
name String
|
|
slug String @unique
|
|
sort Int @default(0)
|
|
products Product[]
|
|
}
|
|
|
|
model Product {
|
|
id String @id @default(cuid())
|
|
title String
|
|
slug String @unique
|
|
shortDescription String?
|
|
description String?
|
|
/// Количество на складе (если null — не ведём учёт)
|
|
quantity Int?
|
|
/// Материалы (список, например: ["хлопок","дерево"])
|
|
materials String @default("[]")
|
|
/// Цена в копейках (целое число, без дробной части)
|
|
priceCents Int
|
|
imageUrl String?
|
|
published Boolean @default(false)
|
|
inStock Boolean @default(true)
|
|
leadTimeDays Int?
|
|
category Category @relation(fields: [categoryId], references: [id], onDelete: Cascade)
|
|
categoryId String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
images ProductImage[]
|
|
}
|
|
|
|
model ProductImage {
|
|
id String @id @default(cuid())
|
|
url String
|
|
sort Int @default(0)
|
|
createdAt DateTime @default(now())
|
|
|
|
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
|
productId String
|
|
|
|
@@index([productId, sort])
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
email String @unique
|
|
name String?
|
|
phone String?
|
|
passwordHash String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
codes AuthCode[]
|
|
addresses ShippingAddress[]
|
|
}
|
|
|
|
model ShippingAddress {
|
|
id String @id @default(cuid())
|
|
label String?
|
|
recipientName String
|
|
recipientPhone String
|
|
addressLine String
|
|
comment String?
|
|
lat Float
|
|
lng Float
|
|
isDefault Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String
|
|
|
|
@@index([userId, isDefault])
|
|
@@index([userId, updatedAt])
|
|
}
|
|
|
|
model AuthCode {
|
|
id String @id @default(cuid())
|
|
email String
|
|
codeHash String
|
|
purpose String
|
|
expiresAt DateTime
|
|
usedAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
|
|
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String?
|
|
|
|
@@index([email, purpose])
|
|
@@index([expiresAt])
|
|
}
|