waiting for postgress in script
This commit is contained in:
parent
e36b319ea2
commit
fb952729ec
|
@ -10,7 +10,6 @@ get_abs_filename() {
|
||||||
|
|
||||||
PROJECT_DIR="$(get_abs_filename $0)/.."
|
PROJECT_DIR="$(get_abs_filename $0)/.."
|
||||||
|
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
# cleaning sqlite db
|
# cleaning sqlite db
|
||||||
echo "Removing /tmp/foo"
|
echo "Removing /tmp/foo"
|
||||||
|
@ -31,7 +30,7 @@ poetry install
|
||||||
. "$(poetry env info -p)/bin/activate"
|
. "$(poetry env info -p)/bin/activate"
|
||||||
|
|
||||||
# I create a new SQLite db to run the migrations and generate a new one
|
# I create a new SQLite db to run the migrations and generate a new one
|
||||||
echo("Generating SQLite migrations")
|
echo "Generating SQLite migrations"
|
||||||
export DYNACONF_DB_URL="sqlite:///tmp/tmp.db"
|
export DYNACONF_DB_URL="sqlite:///tmp/tmp.db"
|
||||||
cd "$PROJECT_DIR/mobilizon_reshare/migrations/sqlite/"
|
cd "$PROJECT_DIR/mobilizon_reshare/migrations/sqlite/"
|
||||||
|
|
||||||
|
@ -41,14 +40,21 @@ aerich migrate
|
||||||
# I use a dedicated docker-compose file to spin up a postgres instance, connect to it, run the migrations and generate a
|
# I use a dedicated docker-compose file to spin up a postgres instance, connect to it, run the migrations and generate a
|
||||||
# new one
|
# new one
|
||||||
|
|
||||||
echo("Generating postgres migrations")
|
echo "Generating postgres migrations"
|
||||||
export DYNACONF_DB_URL="postgres://mobilizon_reshare:mobilizon_reshare@localhost:5432/mobilizon_reshare"
|
export DYNACONF_DB_URL="postgres://mobilizon_reshare:mobilizon_reshare@localhost:5432/mobilizon_reshare"
|
||||||
cd $PROJECT_DIR
|
cd $PROJECT_DIR
|
||||||
|
|
||||||
docker-compose -f docker-compose-migration.yml up -d
|
docker-compose -f docker-compose-migration.yml up -d
|
||||||
|
|
||||||
cd "$PROJECT_DIR/mobilizon_reshare/migrations/postgres/"
|
cd "$PROJECT_DIR/mobilizon_reshare/migrations/postgres/"
|
||||||
|
until [ "$(docker inspect mo-re_db_1 --format='{{json .State.Health.Status}}')" = "\"healthy\"" ];
|
||||||
|
do
|
||||||
|
echo "Waiting for postgres"
|
||||||
|
if [ "$(docker inspect mo-re_db_1 --format='{{json .State.Health.Status}}')" = "\"healthy\"" ]
|
||||||
|
then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1s
|
||||||
|
done
|
||||||
aerich upgrade
|
aerich upgrade
|
||||||
aerich migrate
|
aerich migrate
|
||||||
|
|
||||||
cleanup
|
|
Loading…
Reference in New Issue