update backend scripts

This commit is contained in:
appflowy 2021-12-01 17:39:23 +08:00
parent 6504863586
commit e1ed027b9c
2 changed files with 16 additions and 11 deletions

View File

@ -1,11 +1,10 @@
.EXPORT_ALL_VARIABLES:
export DB_USER=postgres
export DB_PASSWORD=password
export DB_NAME=flowy
export DB_PORT=5433
export DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}
export ROOT = "./scripts/database"
export DB_HOST = "localhost"
#.EXPORT_ALL_VARIABLES:
#export DB_USER=postgres
#export DB_PASSWORD=password
#export DB_NAME=flowy
#export DB_PORT=5433
#export DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}
#export DB_HOST = "localhost"
init_database:
${ROOT}/init_database.sh

View File

@ -13,11 +13,17 @@ fi
if ! [ -x "$(command -v sqlx)" ]; then
echo >&2 "Error: `sqlx` is not installed."
echo >&2 "Use:"
echo >&2 " cargo install --version=^0.5.6 sqlx-cli --no-default-features --features postgres"
echo >&2 " cargo install --version=^0.5.7 sqlx-cli --no-default-features --features postgres"
echo >&2 "to install it."
exit 1
fi
DB_USER="${POSTGRES_USER:=postgres}"
DB_PASSWORD="${POSTGRES_PASSWORD:=password}"
DB_PORT="${POSTGRES_PORT:=5433}"
DB_HOST="${POSTGRES_HOST:=localhost}"
DB_NAME="${POSTGRES_DB:=flowy}"
if [[ -z "${SKIP_DOCKER}" ]]
then
RUNNING_POSTGRES_CONTAINER=$(docker ps --filter 'name=postgres' --format '{{.ID}}')
@ -28,12 +34,12 @@ then
fi
docker run \
--name="flowy" \
-e POSTGRES_USER=${DB_USER} \
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
-e POSTGRES_DB=${DB_NAME} \
-e POSTGRES_DB="${DB_NAME}" \
-p "${DB_PORT}":5432 \
-d postgres \
--name "postgres_$(date '+%s')" \
postgres -N 1000
fi