From 8453ab9ae978167ad527008c893f3f4d8de74e65 Mon Sep 17 00:00:00 2001 From: Jakob Lechner Date: Sun, 20 Jul 2025 16:54:59 +0200 Subject: [PATCH] Add database initialization Runs fieldpoc with `--init` if there are no tables in the database. --- nix/modules/fieldpoc.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nix/modules/fieldpoc.nix b/nix/modules/fieldpoc.nix index b4376db..643dab6 100644 --- a/nix/modules/fieldpoc.nix +++ b/nix/modules/fieldpoc.nix @@ -78,6 +78,10 @@ in { if [ ! -f "/var/lib/fieldpoc/extensions.json" ]; then echo '{"extensions": {}}' > /var/lib/fieldpoc/extensions.json fi + + if [ $(${config.services.postgresql.finalPackage}/bin/psql -q -t -A -c "select count(*) from information_schema.tables where table_schema='fieldpoc';") -eq 0 ]; then + ${pkgs.fieldpoc}/bin/fieldpoc -c /run/fieldpoc/config.json --debug --init + fi ''; };