feat: add postgres to justfile for nix

This commit is contained in:
Alejandro Baez 2022-07-30 14:11:41 -05:00 committed by Mayel de Borniol
parent 90a9b65658
commit 3a60d80ea8
2 changed files with 16 additions and 0 deletions

View file

@ -122,6 +122,18 @@
export PATH="$MIX_PATH/bin:$HEX_HOME/bin:$PATH"
mix local.rebar --if-missing rebar3 ${rebar3}/bin/rebar3;
mix local.rebar --if-missing rebar ${rebar}/bin/rebar;
export PGDATA=$PWD/db
export PGHOST=$PGDATA
export PGUSERNAME=$POSTGRES_USER
export PGPASS=$POSTGRES_PASSWORD
export PGDATABASE=$POSTGRES_DB
if [[ ! -d $PGDATA ]]; then
mkdir $PGDATA
# comment out if not using CoW fs
chattr +C $PGDATA
initdb -D $PGDATA
fi
'';
buildInputs = [

View file

@ -559,3 +559,7 @@ db-pre-migrations:
secrets:
@cd lib/mix/tasks/secrets/ && mix escript.build && ./secrets 128 3
# start or stop nix postgres server
nix-pg pg_cmd:
@pg_ctl -D ${PGDATA} -l ${PGDATA}/all.log -o "--unix_socket_directories='${PGDATA}'" $pg_cmd