82 lines
2.0 KiB
Plaintext
82 lines
2.0 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
// --------------------------------------------------------------------
|
|
// Users
|
|
//
|
|
// There are exactly two users in this application. Their credentials
|
|
// (username + bcrypt hash) live in env — see apps/backend/src/config/env.ts.
|
|
// The DB stores only "public" fields to scope wishes and serve public
|
|
// profiles. The password hash is intentionally NOT stored here; this keeps
|
|
// the single source of truth for credentials in env and limits the
|
|
// blast-radius of a DB dump.
|
|
// --------------------------------------------------------------------
|
|
model User {
|
|
id String @id
|
|
username String @unique
|
|
slug String @unique
|
|
displayName String
|
|
bio String?
|
|
avatarUrl String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
wishes Wish[]
|
|
}
|
|
|
|
enum WishStatus {
|
|
ACTIVE
|
|
ARCHIVED
|
|
COMPLETED
|
|
DELETED
|
|
}
|
|
|
|
enum ImageSource {
|
|
DEFAULT
|
|
OG
|
|
UPLOADED
|
|
}
|
|
|
|
model Wish {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
title String
|
|
price Decimal? @db.Decimal(12, 2)
|
|
currency String @default("RUB")
|
|
url String?
|
|
comment String?
|
|
imageUrl String?
|
|
imageSource ImageSource @default(DEFAULT)
|
|
status WishStatus @default(ACTIVE)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
archivedAt DateTime?
|
|
completedAt DateTime?
|
|
deletedAt DateTime?
|
|
sourceWishId String?
|
|
|
|
views GuestView[]
|
|
|
|
@@index([userId, status])
|
|
@@index([deletedAt])
|
|
@@index([createdAt])
|
|
}
|
|
|
|
model GuestView {
|
|
id String @id @default(cuid())
|
|
guestId String
|
|
wishId String
|
|
wish Wish @relation(fields: [wishId], references: [id], onDelete: Cascade)
|
|
seenAt DateTime @default(now())
|
|
|
|
@@unique([guestId, wishId])
|
|
@@index([guestId])
|
|
}
|