Skip to content

Commit 78ae959

Browse files
Pg repack update (#327)
2 parents 0fab313 + dc5ac4f commit 78ae959

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

modules/postgres.nix

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,16 @@ in
389389
(lib.mkIf (cfg.enableAllPreloadedLibraries || cfg.configurePgStatStatements) (lib.concatStrings (map (db:
390390
(lib.concatMapStringsSep "\n" (ext: let
391391
# This is ugly...
392-
ext' = lib.head (lib.splitString "-" ext);
392+
extName = lib.head (lib.splitString "-" ext);
393+
394+
extUpdateStatement = name: {
395+
# pg_repack cannot be updated but reinstalling it is safe
396+
"pg_repack" = "DROP EXTENSION pg_repack; CREATE EXTENSION pg_repack";
397+
"postgis" = "SELECT postgis_extensions_upgrade()";
398+
}.${name} or ''ALTER EXTENSION "${extName}" UPDATE'';
393399
in /* bash */ ''
394-
$PSQL -tAd '${db}' -c 'CREATE EXTENSION IF NOT EXISTS "${ext'}"'
395-
$PSQL -tAd '${db}' -c '${if ext' == "postgis" then
396-
"SELECT postgis_extensions_upgrade()"
397-
else
398-
''ALTER EXTENSION "${ext'}" UPDATE''}'
400+
$PSQL -tAd '${db}' -c 'CREATE EXTENSION IF NOT EXISTS "${extName}"'
401+
$PSQL -tAd '${db}' -c '${extUpdateStatement extName}'
399402
'') (lib.splitString "," (if cfg.enableAllPreloadedLibraries then
400403
cfg.settings.shared_preload_libraries
401404
else if cfg.configurePgStatStatements then

0 commit comments

Comments
 (0)