initial commit
This commit is contained in:
43
prisma/schema.prisma
Normal file
43
prisma/schema.prisma
Normal file
@@ -0,0 +1,43 @@
|
||||
generator client {
|
||||
provider = "prisma-client"
|
||||
output = "../generated/prisma"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
}
|
||||
|
||||
model Pet {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
species String
|
||||
userId String
|
||||
|
||||
posts Post[] // One pet can have many posts
|
||||
|
||||
sentRequests Friendship[] @relation("sentRequests")
|
||||
receivedRequests Friendship[] @relation("receivedRequests")
|
||||
}
|
||||
|
||||
model Friendship {
|
||||
id Int @id @default(autoincrement())
|
||||
|
||||
petId Int
|
||||
friendId Int
|
||||
|
||||
pet Pet @relation("sentRequests", fields: [petId], references: [id])
|
||||
friend Pet @relation("receivedRequests", fields: [friendId], references: [id])
|
||||
|
||||
accepted Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
// 3. Safety: A pet can't friend the same pet twice
|
||||
@@unique([petId, friendId])
|
||||
}
|
||||
|
||||
model Post {
|
||||
id Int @id @default(autoincrement())
|
||||
content String
|
||||
petId Int @map("pet_id")
|
||||
pet Pet @relation(fields: [petId], references: [id])
|
||||
}
|
||||
Reference in New Issue
Block a user