Pull initdb into a function; have db commands exec instead of run to ensure container is up

This commit is contained in:
Jim Fingal 2020-11-08 11:50:20 -08:00
parent f1816d2ef5
commit 0176f5bbf8
1 changed files with 11 additions and 6 deletions

17
fr-dev
View File

@ -9,30 +9,35 @@ function clean {
} }
function rundb { function rundb {
docker-compose run --rm db $@ docker-compose exec db $@
} }
function runweb { function runweb {
docker-compose run --rm web $@ docker-compose run --rm web $@
} }
function initdb {
runweb python manage.py migrate
runweb python manage.py initdb
}
case "$1" in case "$1" in
up) up)
docker-compose up --build docker-compose up --build
;; ;;
run) run)
docker-compose run --service-ports web docker-compose run --rm --service-ports web
;; ;;
initdb) initdb)
runweb python manage.py migrate initdb
runweb python manage.py initdb
;; ;;
resetdb) resetdb)
clean clean
docker-compose up --build -d
rundb dropdb -U fedireads fedireads rundb dropdb -U fedireads fedireads
rundb createdb -U fedireads fedireads rundb createdb -U fedireads fedireads
runweb python manage.py migrate initdb
runweb python manage.py initdb clean
;; ;;
makemigrations) makemigrations)
runweb python manage.py makemigrations runweb python manage.py makemigrations