66 lines
1.5 KiB
Plaintext
66 lines
1.5 KiB
Plaintext
generator client {
|
||
provider = "prisma-client-js"
|
||
}
|
||
|
||
datasource db {
|
||
provider = "postgresql" // oder mysql / sqlite – bei Bedarf anpassen
|
||
url = env("DATABASE_URL")
|
||
}
|
||
|
||
model User {
|
||
id Int @id @default(autoincrement())
|
||
name String
|
||
email String @unique
|
||
|
||
pets Pet[]
|
||
posts Post[]
|
||
|
||
following Follow[] @relation("Follower")
|
||
followers Follow[] @relation("Following")
|
||
|
||
createdAt DateTime @default(now())
|
||
}
|
||
|
||
|
||
model Pet {
|
||
id Int @id @default(autoincrement())
|
||
name String
|
||
type String // "Hund" | "Katze"
|
||
breed String
|
||
birthDate DateTime? // ⭐ Single Source of Truth für Alter
|
||
gender String?
|
||
bio String?
|
||
avatarUrl String?
|
||
visibility String @default("public") // public | followers
|
||
|
||
ownerId Int
|
||
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
|
||
|
||
posts Post[]
|
||
}
|
||
|
||
model Post {
|
||
id Int @id @default(autoincrement())
|
||
content String?
|
||
createdAt DateTime @default(now())
|
||
|
||
petId Int
|
||
pet Pet @relation(fields: [petId], references: [id], onDelete: Cascade)
|
||
|
||
authorId Int
|
||
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
|
||
}
|
||
model Follow {
|
||
id Int @id @default(autoincrement())
|
||
|
||
followerId Int
|
||
follower User @relation("Follower", fields: [followerId], references: [id], onDelete: Cascade)
|
||
|
||
followingId Int
|
||
following User @relation("Following", fields: [followingId], references: [id], onDelete: Cascade)
|
||
|
||
createdAt DateTime @default(now())
|
||
|
||
@@unique([followerId, followingId])
|
||
}
|