nixos/postgresql: allow specifying multiple databases in ensureDBOwnership#287788
nixos/postgresql: allow specifying multiple databases in ensureDBOwnership#287788icewind1991 wants to merge 2 commits intoNixOS:masterfrom icewind1991:postgres-ensureDBOwnership-list
Conversation
|
FYI, there are related discussions in #266270 and you can request people interested to review this PR. |
ambroisie
left a comment
There was a problem hiding this comment.
This is what I had in mind, so let me approve the PR :-).
Tiny nit to DRY it up.
There was a problem hiding this comment.
Rather than repeat this multiple time, you can use apply in the option definition to tranform a true into a singleton list [ name ].
There was a problem hiding this comment.
I tried that but couldn't figure out how to use the value of name within the apply function
There was a problem hiding this comment.
types.submodule can use an argument list which would allow you to get at the name IIRC.
Currently on my phone so it's difficult to check.
|
So I happen to have a database owned by a differently-named user and the database has data in it. Now I understand that I can just comment out the whole bit and the existing database will not be impacted, but I'd rather modernize the config properly, so: what's up with this PR? It's been quiet for a month, how do the prospects look? |
| in concatStringsSep "\n" | ||
| (builtins.map (db: ''$PSQL -tAc 'ALTER DATABASE "${db}" OWNER TO "${user.name}";' '') dbOwnershipList); |
There was a problem hiding this comment.
| in concatStringsSep "\n" | |
| (builtins.map (db: ''$PSQL -tAc 'ALTER DATABASE "${db}" OWNER TO "${user.name}";' '') dbOwnershipList); | |
| in concatMapStringsSep "\n" | |
| (db: ''$PSQL -tAc 'ALTER DATABASE "${db}" OWNER TO "${user.name}";' '') dbOwnershipList; |
Description of changes
Allow settings
services.postgresql.ensureUsers.*.ensureDBOwnershipto a list of database names instead of only booleans.This allows using it for setups where the database name doesn't match the user name or there are multiple databases accessed by a single db user.
This should make
ensureDBOwnershipable to cover more use cases from the deprecatedensurePermissionsoption.Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.