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>master
parent
caa30ff2f1
commit
71aba798d3
|
@ -25258,7 +25258,21 @@ The role permissions list. Supported permissions are @code{bypassrls},
|
||||||
@code{superuser}.
|
@code{superuser}.
|
||||||
|
|
||||||
@item @code{create-database?} (default: @code{#f})
|
@item @code{create-database?} (default: @code{#f})
|
||||||
Whether to create a database with the same name as the role.
|
whether to create a database with the same name as the role.
|
||||||
|
|
||||||
|
@item @code{encoding} (default: @code{"UTF8"})
|
||||||
|
The character set to use for storing text in the database.
|
||||||
|
|
||||||
|
@item @code{collation} (default: @code{"en_US.utf8"})
|
||||||
|
The string sort order locale setting.
|
||||||
|
|
||||||
|
@item @code{ctype} (default: @code{"en_US.utf8"})
|
||||||
|
The character classification locale setting.
|
||||||
|
|
||||||
|
@item @code{template} (default: @code{"template1"})
|
||||||
|
The default template to copy the new database from when creating it.
|
||||||
|
Use @code{"template0"} for a pristine database with no system-local
|
||||||
|
modifications.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
@end deftp
|
@end deftp
|
||||||
|
|
|
@ -363,7 +363,15 @@ and stores the database cluster in @var{data-directory}."
|
||||||
(permissions postgresql-role-permissions
|
(permissions postgresql-role-permissions
|
||||||
(default '(createdb login))) ;list
|
(default '(createdb login))) ;list
|
||||||
(create-database? postgresql-role-create-database? ;boolean
|
(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>
|
(define-record-type* <postgresql-role-configuration>
|
||||||
postgresql-role-configuration make-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
|
(append-map
|
||||||
(lambda (role)
|
(lambda (role)
|
||||||
(match-record role <postgresql-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 \
|
`("SELECT NOT(EXISTS(SELECT 1 FROM pg_catalog.pg_roles WHERE \
|
||||||
rolname = '" ,name "')) as not_exists;\n"
|
rolname = '" ,name "')) as not_exists;\n"
|
||||||
"\\gset\n"
|
"\\gset\n"
|
||||||
|
@ -402,7 +411,11 @@ rolname = '" ,name "')) as not_exists;\n"
|
||||||
";\n"
|
";\n"
|
||||||
,@(if create-database?
|
,@(if create-database?
|
||||||
`("CREATE DATABASE \"" ,name "\""
|
`("CREATE DATABASE \"" ,name "\""
|
||||||
" OWNER \"" ,name "\";\n")
|
" OWNER \"" ,name "\"\n"
|
||||||
|
" ENCODING '" ,encoding "'\n"
|
||||||
|
" LC_COLLATE '" ,collation "'\n"
|
||||||
|
" LC_CTYPE '" ,ctype "'\n"
|
||||||
|
" TEMPLATE " ,template ";")
|
||||||
'())
|
'())
|
||||||
"\\endif\n")))
|
"\\endif\n")))
|
||||||
roles)))
|
roles)))
|
||||||
|
|
Reference in New Issue