webdevbroz / nutrient-checker

check the nutritional content of your meals, identify missing nutrients, and receive personalized food recommendations to optimize your diet.
1 stars 0 forks source link

Create local postGres #8

Open tds455 opened 7 months ago

tds455 commented 7 months ago

sudo docker run --name postgresdev -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=enterpassword -e POSTGRES_DB=prod -p 60000:5432 -d postgres:latest

sudo cat backup.sql | sudo docker exec -i postgresdev psql -U postgres

sudo docker exec -it postgresdev bash

tds455 commented 7 months ago

https://github.com/webdevbroz/nutrient-checker/commit/61522e1ac96586685183d905bb5cb551f883c071

added backup.sql

tds455 commented 7 months ago

I have added a file - restoredb.sh.

This will configure a psql container and restore the latest backup of the prod database.

Next step will be to automatically create daily backups of prod db.

To use this file a DB_PW environment variable must be set with the current DB password

Evomatic commented 7 months ago

Well done with the script, This will make the local dev setup more smooth. I did run into some issues on my end though, so I refactored the script a bit to handle errors and provide messages for each step.

tds455 commented 7 months ago

Updated to do: add food_category table to allow queries on specific categories

Evomatic commented 7 months ago

Want to look into adding the django rest api framework: https://www.django-rest-framework.org/