diff --git a/README.md b/README.md index 53640253..3159cdee 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/backend/typescript/prisma/schema.prisma b/backend/typescript/prisma/schema.prisma index abfb9d6b..ca135c89 100644 --- a/backend/typescript/prisma/schema.prisma +++ b/backend/typescript/prisma/schema.prisma @@ -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 { @@ -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? @@ -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]) }