summaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorMiguel Moreno <mmoreno@mmoreno.eu>2023-03-27 19:30:45 +0200
committerLudovic Courtès <ludo@gnu.org>2023-08-11 00:50:48 +0200
commit71aba798d3d586a42afe8a61e8e36b95ca41bc37 (patch)
tree2cdebcb470b55e3df24212d814977e2bffc3ffce /gnu/services
parentcaa30ff2f13a149810e564ab9b1737e057345032 (diff)
services: postgresql: Add more role fields.
* gnu/services/databases.scm (postgresql-role): Add more role fields. (postgresql-create-roles): Honor it. * doc/guix.texi (Database Services): Document it. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/databases.scm19
1 files changed, 16 insertions, 3 deletions
diff --git a/gnu/services/databases.scm b/gnu/services/databases.scm
index e8e42d3b7b..7148971c1d 100644
--- a/gnu/services/databases.scm
+++ b/gnu/services/databases.scm
@@ -363,7 +363,15 @@ and stores the database cluster in @var{data-directory}."
(permissions postgresql-role-permissions
(default '(createdb login))) ;list
(create-database? postgresql-role-create-database? ;boolean
- (default #f)))
+ (default #f))
+ (encoding postgresql-role-encoding ;string
+ (default "UTF8"))
+ (collation postgresql-role-collation ;string
+ (default "en_US.utf8"))
+ (ctype postgresql-role-ctype ;string
+ (default "en_US.utf8"))
+ (template postgresql-role-template ;string
+ (default "template1")))
(define-record-type* <postgresql-role-configuration>
postgresql-role-configuration make-postgresql-role-configuration
@@ -392,7 +400,8 @@ and stores the database cluster in @var{data-directory}."
(append-map
(lambda (role)
(match-record role <postgresql-role>
- (name permissions create-database?)
+ (name permissions create-database? encoding collation ctype
+ template)
`("SELECT NOT(EXISTS(SELECT 1 FROM pg_catalog.pg_roles WHERE \
rolname = '" ,name "')) as not_exists;\n"
"\\gset\n"
@@ -402,7 +411,11 @@ rolname = '" ,name "')) as not_exists;\n"
";\n"
,@(if create-database?
`("CREATE DATABASE \"" ,name "\""
- " OWNER \"" ,name "\";\n")
+ " OWNER \"" ,name "\"\n"
+ " ENCODING '" ,encoding "'\n"
+ " LC_COLLATE '" ,collation "'\n"
+ " LC_CTYPE '" ,ctype "'\n"
+ " TEMPLATE " ,template ";")
'())
"\\endif\n")))
roles)))