diff --git a/site-cookbooks/kosmos-postgresql/recipes/default.rb b/site-cookbooks/kosmos-postgresql/recipes/default.rb index be288d6..2b8e09b 100644 --- a/site-cookbooks/kosmos-postgresql/recipes/default.rb +++ b/site-cookbooks/kosmos-postgresql/recipes/default.rb @@ -37,6 +37,19 @@ service postgresql_service do action [:enable] end +# This will only be run once, if the /var/lib/postgresql/10/main directory +# exists. The old data directory is then moved. +execute "upgrade postgresql to 12" do + command <<-EOF +systemctl stop postgresql@12-main +systemctl stop postgresql@10-main +su - postgres -c "/usr/lib/postgresql/12/bin/pg_upgrade --old-bindir=/usr/lib/postgresql/10/bin/ --new-bindir=/usr/lib/postgresql/12/bin/ --old-datadir=/etc/postgresql/10/main/ --new-datadir=/etc/postgresql/12/main/" +mv /var/lib/postgresql/10/main /var/lib/postgresql/10/main.old +systemctl start postgresql@12-main + EOF + only_if { ::File.exist? "/var/lib/postgresql/10/main" } +end + postgresql_replicas.each do |replica| postgresql_access "#{replica[:hostname]} replication" do access_type "host"