Skip to content

Commit

Permalink
feat: add neon db (#21)
Browse files Browse the repository at this point in the history
* feat: add neon db

* fix: add optional neon setup
  • Loading branch information
williamtran10 authored Nov 9, 2023
1 parent 8a8e4c8 commit bf2318c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
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])
}

0 comments on commit bf2318c

Please sign in to comment.