Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add neon db #21

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ docker-compose up --build
The backend runs at http://localhost:5000 and the frontend runs at http://localhost:3000. By default, we use GraphQL (with TypeScript backend), REST (with Python backend), MongoDB, with user auth.

### Note: Manual Database Setup

If for some reason docker container is not syncing with your prisma models in backend/typescript/prisma/schema

Update .env file in /backend/typescript to be
Expand All @@ -91,6 +92,11 @@ nvm install 18.16.0
nvm use 18.16.0
```

## Creating Prisma Migration

Go to `backend/typescript` and run

npx prisma migrate dev

## Useful Commands

Expand Down
46 changes: 25 additions & 21 deletions backend/typescript/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ generator client {
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
// uncomment this for neon db
// directUrl = env("DIRECT_URL")
}

model post {
id Int @id @default(autoincrement())
created_at DateTime @default(now())
updated_at DateTime @updatedAt
title String @db.VarChar(255)
content String?
published Boolean @default(false)
author_id Int
author user @relation(fields: [author_id], references: [id])
id Int @id @default(autoincrement())
created_at DateTime @default(now())
updated_at DateTime @updatedAt
title String @db.VarChar(255)
content String?
published Boolean @default(false)
author_id Int
author user @relation(fields: [author_id], references: [id])
}

model profile {
Expand Down Expand Up @@ -106,10 +108,10 @@ model role {
}

model resident {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
first_name String
last_name String
email String @unique
email String @unique
phone_number String?
display_name String
profile_picture_link String?
Expand All @@ -123,18 +125,20 @@ model resident {
}

model notification {
id Int @id @default(autoincrement())
message String
author_id Int
author staff @relation(fields: [author_id], references: [id])
created_at DateTime @default(now())
residents notification_user[]
id Int @id @default(autoincrement())
message String
author_id Int
author staff @relation(fields: [author_id], references: [id])
created_at DateTime @default(now())
residents notification_user[]
}

model notification_user {
notification notification @relation(fields: [notification_id], references: [id])
notification_id Int
recipient resident @relation(fields: [recipient_id], references: [id])
recipient_id Int
seen Boolean @default(false)
notification notification @relation(fields: [notification_id], references: [id])
notification_id Int
recipient resident @relation(fields: [recipient_id], references: [id])
recipient_id Int
seen Boolean @default(false)

@@id([notification_id, recipient_id])
}