diff --git a/nixos/modules/services/databases/postgresql.xml b/nixos/modules/services/databases/postgresql.xml
index 0ca9f3faed21..e48c578e6ce6 100644
--- a/nixos/modules/services/databases/postgresql.xml
+++ b/nixos/modules/services/databases/postgresql.xml
@@ -72,16 +72,20 @@ Type "help" for help.
{ config, pkgs, ... }:
{
= [
- (pkgs.writeScriptBin "upgrade-pg-cluster" ''
+ (let
+ # XXX specify the postgresql package you'd like to upgrade to.
+ # Do not forget to list the extensions you need.
+ newPostgres = pkgs.postgresql_13.withPackages (pp: [
+ # pp.plv8
+ ]);
+ in pkgs.writeScriptBin "upgrade-pg-cluster" ''
set -eux
# XXX it's perhaps advisable to stop all services that depend on postgresql
systemctl stop postgresql
- # XXX replace `<new version>` with the psqlSchema here
- export NEWDATA="/var/lib/postgresql/<new version>"
+ export NEWDATA="/var/lib/postgresql/${newPostgres.psqlSchema}"
- # XXX specify the postgresql package you'd like to upgrade to
- export NEWBIN="${pkgs.postgresql_13}/bin"
+ export NEWBIN="${newPostgres}/bin"
export OLDDATA="${config.}"
export OLDBIN="${config.}/bin"
@@ -127,12 +131,25 @@ Type "help" for help.
- After the upgrade it's advisable to analyze the new cluster (as su -l postgres in the
- , in this example /var/lib/postgresql/13):
+ After the upgrade it's advisable to analyze the new cluster.
+
+
+
+
+ For PostgreSQL ≥ 14, use the vacuumdb command printed by the upgrades script.
+
+
+
+
+ For PostgreSQL < 14, run (as su -l postgres in the , in this example /var/lib/postgresql/13):
$ ./analyze_new_cluster.sh
- The next step removes the old state-directory!
+
+
+
+
+ The next step removes the old state-directory!
$ ./delete_old_cluster.sh