HotTRDealsBackend/prisma/schema.prisma

78 lines
2.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
username String @unique
email String @unique
passwordHash String
avatarUrl String? @db.VarChar(512)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
Deal Deal[]
votes DealVote[]
comments Comment[]
}
model Deal {
id Int @id @default(autoincrement())
title String
description String?
url String?
price Float?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
userId Int
score Int @default(0)
user User @relation(fields: [userId], references: [id])
votes DealVote[]
comments Comment[]
images DealImage[] // ← yeni ilişki
}
model DealImage {
id Int @id @default(autoincrement())
imageUrl String @db.VarChar(512)
order Int @default(0)
createdAt DateTime @default(now())
dealId Int
deal Deal @relation(fields: [dealId], references: [id], onDelete: Cascade)
}
model DealVote {
id Int @id @default(autoincrement())
dealId Int
userId Int
voteType String
createdAt DateTime @default(now())
deal Deal @relation(fields: [dealId], references: [id])
user User @relation(fields: [userId], references: [id])
@@unique([dealId, userId]) // aynı kullanıcı aynı ilana bir kez oy verebilir
}
model Comment {
id Int @id @default(autoincrement())
text String
createdAt DateTime @default(now())
userId Int
dealId Int
user User @relation(fields: [userId], references: [id])
deal Deal @relation(fields: [dealId], references: [id])
}