Improve scripts
This commit is contained in:
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
YORE_DB="host=localhost port=${DB_PORT} user=${DB_USER} dbname=${DB_DBNAME}" cabal repl exe:yore
|
||||
+9
-3
@@ -5,19 +5,25 @@ if [ -z "$BASE_DIR" ]; then
|
||||
fi
|
||||
export PGDATA="$BASE_DIR/pgdata"
|
||||
|
||||
export DB_USER=yore-test
|
||||
export DB_DBNAME=yore-test
|
||||
export DB_PORT=5433
|
||||
|
||||
# On error or exit: Stop the DB server
|
||||
stop_db_server() {
|
||||
pg_ctl stop -o "-p 5433" --wait
|
||||
pg_ctl stop -o "-p ${DB_PORT}" --wait
|
||||
}
|
||||
trap stop_db_server EXIT
|
||||
|
||||
if [ ! -s "$PGDATA/PG_VERSION" ]; then
|
||||
initdb --username=yore-test --auth=trust || true
|
||||
initdb --username="${DB_USER}" --auth=trust || true
|
||||
DO_CREATE_DB=1
|
||||
fi
|
||||
pg_ctl start -o "-p 5433" --wait
|
||||
if [ -n "$DO_CREATE_DB" ]; then
|
||||
createdb -p 5433 yore-test --username=yore-test || true
|
||||
createdb -p "${DB_PORT}" "${DB_DBNAME}" --username="${DB_USER}" || true
|
||||
fi
|
||||
|
||||
DATABASE_URL="postgres://${DB_USER}@localhost:${DB_PORT}/${DB_DBNAME}?sslmode=disable" dbmate up
|
||||
|
||||
"$@"
|
||||
|
||||
Reference in New Issue
Block a user