88 lines
2.2 KiB
Plaintext
88 lines
2.2 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
// include for node docker image
|
|
binaryTargets = ["native", "debian-openssl-1.1.x"]
|
|
previewFeatures = ["interactiveTransactions"]
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Listing {
|
|
id Int @id
|
|
seller Int
|
|
data Json
|
|
|
|
wantId String @db.Uuid
|
|
want Want @relation(fields: [wantId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
|
|
|
offers Offer[]
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([seller])
|
|
@@map("listings")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
email String @unique
|
|
password String
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
wants Want[]
|
|
offers Offer[]
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model Want {
|
|
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
release Int
|
|
data Json
|
|
|
|
userId String @db.Uuid
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
listings Listing[]
|
|
offers Offer[]
|
|
|
|
@@unique([userId, release])
|
|
@@index([release])
|
|
|
|
@@map("wants")
|
|
}
|
|
|
|
model Offer {
|
|
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
|
|
status String
|
|
|
|
item Decimal @db.Money
|
|
shipping Decimal @db.Money
|
|
total Decimal @db.Money
|
|
comparison Decimal @db.Money
|
|
|
|
listingId Int
|
|
listing Listing @relation(fields: [listingId], references: [id])
|
|
|
|
userId String @db.Uuid
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
|
|
|
wantId String @db.Uuid
|
|
want Want @relation(fields: [wantId], references: [id], onDelete: Cascade, onUpdate: Cascade)
|
|
|
|
// only one offer per want for a user
|
|
// @@unique([userId, wantId])
|
|
@@unique([listingId])
|
|
@@map("offers")
|
|
}
|