diff --git a/.envrc.recommended b/.envrc.recommended index 3e08e17..c15f7e6 100644 --- a/.envrc.recommended +++ b/.envrc.recommended @@ -1,3 +1,4 @@ nix_direnv_manual_reload use flake +export DATABASE_URL=postgresql://patagia:secret@/patagia?host=$XDG_RUNTIME_DIR/patagia-postgres dotenv_if_exists diff --git a/justfile b/justfile index cf20a06..ae71f78 100644 --- a/justfile +++ b/justfile @@ -49,8 +49,35 @@ open-api: cargo xtask open-api # Run all tests -check: check-nix +check: check-nix # check-nix check-nix: nix flake check + +# Run PostgreSQL for development and testing +dev-postgres: + mkdir -p "$XDG_RUNTIME_DIR/patagia-postgres" + podman volume exists patagia-postgres || podman volume create patagia-postgres + podman run \ + --detach \ + --replace \ + --name patagia-postgres \ + --env POSTGRES_DB=patagia \ + --env POSTGRES_USER=patagia \ + --env POSTGRES_PASSWORD=secret \ + --volume patagia-postgres:/var/lib/postgresql/data \ + --volume "$XDG_RUNTIME_DIR/patagia-postgres:/var/run/postgresql" \ + docker.io/postgres:17 + +# Reset PostgreSQL data and start +dev-postgres-reset: dev-postgres-clean dev-postgres + +# Clean up PostgreSQL data +dev-postgres-clean: + podman rm -f patagia-postgres || true + podman volume rm patagia-postgres || true + +# Connect to PostgreSQL with psql +dev-postgres-psql: + podman exec -it patagia-postgres psql -U patagia