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

Feature/add category field #339

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
If you prefer running postgres using docker,
I included a docker-compose.yaml file to spin an instance.\
#### Steps
1. Create a .env file if you dont have one in this directory.
2. Add the environment variables:
```bash
#prisma URL
DATABASE_URL=postgres://username:password@localhost:5432/airbnb #my db is airbnb


# DATABASE CREDENTIALS
POSTGRES_USER=username
POSTGRES_DB=airbnb
POSTGRES_PASSWORD=password
POSTGRES_HOST=localhost
POSTGRES_PORT=5432

#PG ADMIN credentials if needed
[email protected]
PGADMIN_PASSWORD=admin
```
3. Run `docker-compose up` or `docker-compose -d`
4. When the images are pulled and container started, you should be ready to run the migrations



27 changes: 27 additions & 0 deletions server/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
services:
postgres:
image: postgres:13
container_name: web-circle-pg
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "5432:5432"
volumes:
- web_circle_pg_data:/var/lib/postgresql/data

pgadmin:
image: dpage/pgadmin4
container_name: web-circle-pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD}
ports:
- "5050:80"
volumes:
- web_circle_pgadmin_data:/var/lib/pgadmin

volumes:
web_circle_pg_data:
web_circle_pgadmin_data:
77 changes: 41 additions & 36 deletions server/package-lock.json

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

8 changes: 6 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -9,11 +9,14 @@
"test": "mocha tests/**/*.js --exit",
"seed": "node prisma/seed.js"
},
"prisma": {
"seed": "node prisma/seed.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@prisma/client": "^5.22.0",
"@prisma/client": "^6.0.1",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.21.1"
@@ -22,7 +25,8 @@
"chai": "^4.5.0",
"mocha": "^10.8.2",
"nodemon": "^3.1.7",
"prisma": "^5.22.0",
"prisma": "^6.0.1",
"supertest": "^7.0.0"

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- CreateEnum
CREATE TYPE "Category" AS ENUM ('BEACHFRONT', 'LUXE', 'CABINS', 'CASTLES', 'BEACH_HOUSES', 'CHALETS', 'TINY_HOMES', 'RIVERSIDE_CABINS', 'LUXURY_VILLAS', 'AMAZING_POOLS', 'CAMPING', 'ARCTIC', 'CARAVANS', 'TREE_HOUSES', 'FISHING_BOATS', 'SAILBOATS');

-- AlterTable
ALTER TABLE "Product" ADD COLUMN "category" "Category"[];
22 changes: 22 additions & 0 deletions server/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -13,6 +13,27 @@ datasource db {
url = env("DATABASE_URL")
}

enum Category {
BEACHFRONT
LUXE
CABINS
CASTLES
BEACH_HOUSES
CHALETS
TINY_HOMES
RIVERSIDE_CABINS
LUXURY_VILLAS
AMAZING_POOLS
CAMPING
ARCTIC
CARAVANS
TREE_HOUSES
FISHING_BOATS
SAILBOATS
}



model Product {
product_id Int @id @default(autoincrement())
title String @db.VarChar(150)
@@ -21,6 +42,7 @@ model Product {
price String
accommodation String @db.VarChar(150)
address String @db.VarChar(150)
category Category[]
guests Int
bedrooms Int
beds Int
Loading
Loading