Add migrations directory for temporary helpers
This commit is contained in:
parent
14228644e6
commit
825d350ab4
3 changed files with 33 additions and 2 deletions
|
|
@ -13,8 +13,6 @@ in
|
||||||
./transcode.nix
|
./transcode.nix
|
||||||
./development.nix
|
./development.nix
|
||||||
./bspwm.nix
|
./bspwm.nix
|
||||||
|
|
||||||
# ./open-pgsql.nix
|
|
||||||
];
|
];
|
||||||
|
|
||||||
nixpkgs.overlays = let
|
nixpkgs.overlays = let
|
||||||
|
|
|
||||||
33
migrations/pgsql_upgrade.nix
Normal file
33
migrations/pgsql_upgrade.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
{
|
||||||
|
environment.systemPackages = [(
|
||||||
|
let
|
||||||
|
# XXX specify the postgresql package you'd like to upgrade to.
|
||||||
|
# Do not forget to list the extensions you need.
|
||||||
|
newPostgres = pkgs.postgresql_16.withPackages (pp: [
|
||||||
|
# pp.plv8
|
||||||
|
]);
|
||||||
|
cfg = config.services.postgresql;
|
||||||
|
in
|
||||||
|
pkgs.writeScriptBin "upgrade-pg-cluster" ''
|
||||||
|
set -eux
|
||||||
|
# XXX it's perhaps advisable to stop all services that depend on postgresql
|
||||||
|
systemctl stop postgresql
|
||||||
|
|
||||||
|
export NEWDATA="/var/lib/postgresql/${newPostgres.psqlSchema}"
|
||||||
|
export NEWBIN="${newPostgres}/bin"
|
||||||
|
|
||||||
|
export OLDDATA="${cfg.dataDir}"
|
||||||
|
export OLDBIN="${cfg.finalPackage}/bin"
|
||||||
|
|
||||||
|
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
|
||||||
|
cd "$NEWDATA"
|
||||||
|
sudo -u postgres "$NEWBIN/initdb" -D "$NEWDATA" ${lib.escapeShellArgs cfg.initdbArgs}
|
||||||
|
|
||||||
|
sudo -u postgres "$NEWBIN/pg_upgrade" \
|
||||||
|
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
|
||||||
|
--old-bindir "$OLDBIN" --new-bindir "$NEWBIN" \
|
||||||
|
"$@"
|
||||||
|
''
|
||||||
|
)];
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue