From 5650471d72521a233f65fa8262880ed422ebfc76 Mon Sep 17 00:00:00 2001 From: Alexis Pentori Date: Wed, 5 Jun 2024 14:31:40 +0200 Subject: [PATCH] init: adding additional script Signed-off-by: Alexis Pentori --- README.md | 2 ++ templates/init/databases.sql | 3 +++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 059c94a..49a68dd 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,14 @@ postgres_ha_databases: - name: my-db user: my-user pass: my-pass + script: 'CREATE SCHEMA IF NOT EXIST example;' - name: my-other-db user: my-other-user pass: my-other-pass ``` The `user` field is optional. DB name is used by default. +The field `script` is optional and allow to add commands to run when creating the database. Backup settings can be adjusted using: ```yaml diff --git a/templates/init/databases.sql b/templates/init/databases.sql index 12520f3..6603ceb 100644 --- a/templates/init/databases.sql +++ b/templates/init/databases.sql @@ -13,4 +13,7 @@ LOCALE "{{ db.locale }}" TEMPLATE "{{ db.template }}" {% endif %} ; +{% if 'script' in db %} +{{ db.script }} +{% endif %} {% endfor %}