From f7720f0d5abb6dd7ea51854565ba54441156bb58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 29 Aug 2024 15:44:57 +0200 Subject: [PATCH] init: grant permissions on public schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise table creation fails with: ``` ERROR: permission denied for schema public ``` Signed-off-by: Jakub SokoĊ‚owski --- templates/init/databases.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/init/databases.sql b/templates/init/databases.sql index 0da768b..9cf96c4 100644 --- a/templates/init/databases.sql +++ b/templates/init/databases.sql @@ -23,5 +23,7 @@ TEMPLATE "{{ db.template }}" -- Permissions {% for user in postgres_ha_users %} -GRANT {{ user.priv | default("pg_read_all_data") }} ON DATABASE {{ user.db | mandatory }} TO {{ user.name | mandatory }}; +\connect "{{ user.db | mandatory }}"; +GRANT {{ user.priv | default("pg_read_all_data") }} ON DATABASE "{{ user.db | mandatory }}" TO "{{ user.name | mandatory }}"; +GRANT {{ user.priv | default("pg_read_all_data") }} ON SCHEMA public TO "{{ user.name | mandatory }}"; {% endfor %}