From a0c7c6dc950cb83bcb521abe55537a6070bb7895 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 14 Dec 2022 16:50:42 +0000 Subject: [PATCH] #947 FATAL: minimum PostgreSQL version error added to DB deploy --- bin/netdisco-db-deploy | 12 ++++++++++++ bin/netdisco-deploy | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/netdisco-db-deploy b/bin/netdisco-db-deploy index 7be37f27..5972e290 100755 --- a/bin/netdisco-db-deploy +++ b/bin/netdisco-db-deploy @@ -94,6 +94,18 @@ Version 17 onwards deploys schema upgrades for Netdisco 2 =cut my $schema = schema('netdisco'); +my $pg_ver = $schema->storage->dbh->{pg_server_version}; + +if ($pg_ver and $pg_ver < 90600) { + printf "\nFATAL: minimum PostgreSQL version for Netdisco is 9.6, you have %s\n", + (join '.', reverse map {scalar reverse} unpack("(A2)*", reverse $pg_ver)); + print "\nUnfortunately, if you are reading this, you already upgraded Netdisco,"; + print "\nso your only options now are to delete and reinstall Netdisco, or upgrade"; + print "\nyour PostgreSQL installation.\n"; + print "\nPlease always read the Release Notes before upgrading:"; + print "\nhttps://github.com/netdisco/netdisco/wiki/Release-Notes\n"; + die "\n"; +} if (scalar @ARGV and $ARGV[0] and $ARGV[0] eq '--redeploy-all') { $schema->storage->dbh_do( diff --git a/bin/netdisco-deploy b/bin/netdisco-deploy index c124f1bc..21956566 100755 --- a/bin/netdisco-deploy +++ b/bin/netdisco-deploy @@ -146,7 +146,7 @@ else { } sub deploy_db { - system 'netdisco-db-deploy'; + system('netdisco-db-deploy') == 0 or die "\n"; print color 'bold blue'; say 'DB schema update complete.'; print color 'reset';