From 8d64812420d2eb00f97d6ce48789415b6a9fa98d Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar <3998+srid@users.noreply.github.com> Date: Tue, 4 Jun 2024 16:22:09 -0400 Subject: [PATCH] docs(postgresql): Add more elaborate example --- doc/postgresql.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/doc/postgresql.md b/doc/postgresql.md index 67aefdd3..8493d368 100644 --- a/doc/postgresql.md +++ b/doc/postgresql.md @@ -15,6 +15,31 @@ - Run postgres server initialised with a sample database and graphically interact with it using [pgweb](https://github.com/sosedoff/pgweb): +## Guide + +{#init} +### Creating users & tables + +Assuming your initial schema is defined in `./scripts/db.sql`: + +```nix +# In `perSystem.process-compose.` +{ + services.postgres."pg1" = { + enable = true; + initialScript.before = '' + CREATE USER myuser WITH password 'mypasswd'; + ''; + initialDatabases = [ + { + name = "mydb"; + schemas = [ ./scripts/db.sql ]; + } + ]; + }; +} +``` + ## Gotchas {#socket-path}