df-web/setup-postgres.sh

24 lines
537 B
Bash
Raw Normal View History

2022-11-20 07:37:22 -08:00
#! /usr/bin/env bash
# Run on the first time configuring database
if [ ! -d $PGHOST ]; then
mkdir -p $PGHOST
fi
if [ ! -d $PGDATA ]; then
echo 'Initializing postgresql database...'
initdb $PGDATA --auth=trust >/dev/null
fi
pg_ctl start -l $LOG_PATH -o "-c listen_addresses= -c unix_socket_directories=$PGHOST"
# TODO move to alembic migrations
psql $PGDATABASE << EOF
CREATE TABLE routes ( \
creatorName text,
dustPoints float[],
checkPoints float[],
startLocation float,
endLocation float,
createDate text
);