Skip to content

Commit

Permalink
Defined initial prisma schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Glenn-Chiang committed Oct 2, 2023
1 parent 29420cc commit a72038e
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel
Expand Down
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"eslint": "latest",
"eslint-config-next": "latest",
"postcss": "latest",
"prisma": "^5.3.1",
"tailwindcss": "latest",
"typescript": "latest"
}
Expand Down
61 changes: 61 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
name String
posts Post[] @relation("authored")
comments Comment[]
likedPosts Post[] @relation("liked")
pods PodMember[]
createdPods Pod[]
}

model Post {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String @db.VarChar(255)
content String
author User @relation("authored", fields: [authorId], references: [id])
authorId Int
comments Comment[]
likedBy User[] @relation("liked")
}

model Comment {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
content String
author User @relation(fields: [authorId], references: [id])
authorId Int
post Post @relation(fields: [postId], references: [id])
postId Int
}

model Pod {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
name String
members PodMember[]
createdBy User @relation(fields: [creatorId], references: [id])
creatorId Int
}

// Many-to-many relationship between Users and Pods
model PodMember {
memberId Int
member User @relation(fields: [memberId], references: [id])
podId Int
pod Pod @relation(fields: [podId], references: [id])
dateJoined DateTime @default(now())
@@id([memberId, podId])
}

0 comments on commit a72038e

Please sign in to comment.