diff --git a/Guide/deployment.markdown b/Guide/deployment.markdown index 02b790374..5aab08eea 100644 --- a/Guide/deployment.markdown +++ b/Guide/deployment.markdown @@ -318,6 +318,12 @@ deploy-to-nixos ihp-app This will connect to the server via SSH and apply the NixOS configuration to the server. +### Database connectivity + +To easily access to the remote database for debugging purpose, you can use: +```bash +make psql-remote env=ihp-app +``` ### Backward-incompatible database update @@ -336,7 +342,6 @@ Steps to do to start from scratch: - `exit` - `rm /tmp/[your-app].sql` - ## Deploying with Docker Deploying IHP with docker is a good choice for a professional production setup. diff --git a/lib/IHP/Makefile.dist b/lib/IHP/Makefile.dist index 031dbb77b..8864d2fc8 100644 --- a/lib/IHP/Makefile.dist +++ b/lib/IHP/Makefile.dist @@ -100,6 +100,11 @@ postgres: ## Starts the postgresql server psql: ## Connects to the running postgresql server @psql -h $$PWD/build/db -d app +psql-remote: ## Connects to the postgresql server of a deployed instance. + @DB_URL=$$(nix eval .#nixosConfigurations.$$env.config.services.ihp.databaseUrl --raw); \ + echo "Connecting to remote database on $$env"; \ + ssh -t $$env "psql $$DB_URL"; \ + db: Application/Schema.sql Application/Fixtures.sql ## Creates a new database with the current Schema and imports Fixtures.sql (echo "drop schema public cascade; create schema public;" | psql -h $${PWD}/build/db -d app) && \ psql -v ON_ERROR_STOP=1 -h $${PWD}/build/db -d app < "$${IHP_LIB}/IHPSchema.sql" && \