Skip to content

Latest commit

 

History

History
63 lines (40 loc) · 1.33 KB

README.md

File metadata and controls

63 lines (40 loc) · 1.33 KB

Backend

Set up local Postgres DB

Install Docker

Install Docker Desktop for Mac following the official guide.

Start postgres container

Run the script to start the postgres container:

ca-animal-lovers/backend $ ./start-postgres.sh

Connect to postgres container

To connect to the postgres container, fetch the container ID first:

➜  backend git:(ziniz/add-local-db) ✗ docker container ls
CONTAINER ID   IMAGE           COMMAND                  CREATED          STATUS                    PORTS                    NAMES
fae215ff958c   postgres:16.3   "docker-entrypoint.s…"   45 minutes ago   Up 45 minutes (healthy)   0.0.0.0:5432->5432/tcp   caal-postgres

Here fae215ff958c is the container id.

Then open a shell for the postgres container:

$ docker exec -it fae215ff958c sh

In the shell, connect to psql db:

$ psql -U caal

And you are now conencted to the DB.

Populate local DB

Install tsx:

$ sudo npm install tsx -g

Create the dogs table on in your local Postgres DB and populate the table with mock data:

$ DELETE_EXISTING_TABLE=true tsx backend/src/db/populateLocalDB.ts

Start backend server

To start the backend server, from the directory root run

$ npm run start:backend