93 lines
2.7 KiB
Plaintext
93 lines
2.7 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
directUrl = env("DIRECT_URL")
|
|
}
|
|
|
|
model Product {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
description String?
|
|
category String
|
|
availability Boolean @default(true)
|
|
sourceProductId String? // Original ID from the source
|
|
prices Price[]
|
|
watchlistItems WatchlistItem[]
|
|
notifications Notification[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
sourceId Int // Added for the composite unique constraint
|
|
|
|
@@unique([name, sourceId])
|
|
}
|
|
|
|
model Price {
|
|
id Int @id @default(autoincrement())
|
|
productId Int
|
|
product Product @relation(fields: [productId], references: [id])
|
|
sourceId Int
|
|
source Source @relation(fields: [sourceId], references: [id])
|
|
regularPrice Float
|
|
discountedPrice Float?
|
|
discountPercentage Float?
|
|
unitPrice String?
|
|
promotionType String?
|
|
promotionStart DateTime?
|
|
promotionEnd DateTime?
|
|
vatIncluded Boolean @default(true)
|
|
lastUpdated DateTime @default(now())
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model Source {
|
|
id Int @id @default(autoincrement())
|
|
name String @unique
|
|
url String
|
|
logo String?
|
|
lastScraped DateTime?
|
|
prices Price[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model User {
|
|
id Int @id @default(autoincrement())
|
|
email String @unique
|
|
name String?
|
|
watchlist WatchlistItem[]
|
|
notifications Notification[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model WatchlistItem {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
user User @relation(fields: [userId], references: [id])
|
|
productId Int
|
|
product Product @relation(fields: [productId], references: [id])
|
|
createdAt DateTime @default(now())
|
|
|
|
@@unique([userId, productId])
|
|
}
|
|
|
|
model Notification {
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
user User @relation(fields: [userId], references: [id])
|
|
productId Int
|
|
product Product @relation(fields: [productId], references: [id])
|
|
priceThreshold Float?
|
|
percentThreshold Float?
|
|
notifyOnAnyChange Boolean @default(false)
|
|
isActive Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([userId, productId])
|
|
}
|