Update to postgres12
This commit is contained in:
parent
b1edc1a341
commit
a85718a063
3 changed files with 37 additions and 3 deletions
|
@ -81,7 +81,7 @@ let
|
||||||
|
|
||||||
postgresql = {
|
postgresql = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.postgresql_9_6;
|
package = pkgs.postgresql_12;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
systemd = {
|
systemd = {
|
||||||
|
@ -137,7 +137,9 @@ let
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
systemd.services."container@cloud" = { inherit serviceConfig unitConfig; };
|
systemd.services."container@cloud" = { inherit serviceConfig unitConfig; };
|
||||||
systemd.services."container@chor-cloud" = { inherit serviceConfig unitConfig; };
|
systemd.services."container@chor-cloud" = {
|
||||||
|
inherit serviceConfig unitConfig;
|
||||||
|
};
|
||||||
services = {
|
services = {
|
||||||
nginx = {
|
nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
|
@ -35,7 +35,10 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
# Postgres
|
# Postgres
|
||||||
postgresql.enable = true;
|
postgresql = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.postgresql_12;
|
||||||
|
};
|
||||||
|
|
||||||
# Synapse
|
# Synapse
|
||||||
matrix-synapse = let
|
matrix-synapse = let
|
||||||
|
|
29
nixos/roles/update-postgres.nix
Normal file
29
nixos/roles/update-postgres.nix
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
{
|
||||||
|
containers.temp-pg.config.services.postgresql = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.postgresql_12;
|
||||||
|
};
|
||||||
|
environment.systemPackages =
|
||||||
|
let newpg = config.containers.temp-pg.config.services.postgresql;
|
||||||
|
in [
|
||||||
|
(pkgs.writeScriptBin "upgrade-pg-cluster" ''
|
||||||
|
set -x
|
||||||
|
export OLDDATA="${config.services.postgresql.dataDir}"
|
||||||
|
export NEWDATA="${newpg.dataDir}"
|
||||||
|
export OLDBIN="${config.services.postgresql.package}/bin"
|
||||||
|
export NEWBIN="${newpg.package}/bin"
|
||||||
|
|
||||||
|
install -d -m 0700 -o postgres -g postgres "$NEWDATA"
|
||||||
|
cd "$NEWDATA"
|
||||||
|
sudo -u postgres $NEWBIN/initdb -D "$NEWDATA"
|
||||||
|
|
||||||
|
systemctl stop postgresql # old one
|
||||||
|
|
||||||
|
sudo -u postgres $NEWBIN/pg_upgrade \
|
||||||
|
--old-datadir "$OLDDATA" --new-datadir "$NEWDATA" \
|
||||||
|
--old-bindir $OLDBIN --new-bindir $NEWBIN \
|
||||||
|
"$@"
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
}
|
Loading…
Reference in a new issue