]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/update_postgresql_tables.in
Big backport from Enterprise
[bacula/bacula] / bacula / src / cats / update_postgresql_tables.in
index 6690d6018255d3b87f63c83e95d12dffa1e4c7fe..c4564fbfaa46fc1f028cff031112b59d0fd594ec 100644 (file)
@@ -1,13 +1,13 @@
 #!/bin/sh
 #
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2017 Kern Sibbald
 # License: BSD 2-Clause; see file LICENSE-FOSS
 #
 # Shell script to update PostgreSQL tables from Bacula Community version 
-#  5.0.x, 5.2.x, 7.0.x
+#  5.0.x, 5.2.x, 7.0.x, 7.2.x, 7.4.x
 #
 echo " "
-echo "This script will update a Bacula PostgreSQL database from version 12-14 to 15"
+echo "This script will update a Bacula PostgreSQL database from version 12-15 to 16"
 echo " "
 echo "Depending on the current version of your catalog,"
 echo "you may have to run this script multiple times."
@@ -141,6 +141,31 @@ END-OF-DATA
     fi
 fi
 
+if [ "$DBVERSION" -eq 15 ] ; then
+    if psql -f - -d ${db_name} $* <<END-OF-DATA
+begin;
+ALTER TABLE basefiles ALTER COLUMN baseid SET DATA TYPE bigint;
+ALTER TABLE media RENAME COLUMN volparts TO voltype;
+ALTER TABLE media ADD COLUMN volparts INTEGER DEFAULT 0;
+ALTER TABLE media ADD COLUMN volcloudparts INTEGER DEFAULT 0;
+ALTER TABLE media ADD COLUMN lastpartbytes BIGINT DEFAULT 0;
+ALTER TABLE media ADD COLUMN cacheretention BIGINT DEFAULT 0;
+ALTER TABLE pool ADD COLUMN cacheretention BIGINT DEFAULT 0;
+CREATE INDEX job_jobtdate_idx ON job (jobtdate);
+
+UPDATE Version SET VersionId=16;
+commit;
+END-OF-DATA
+    then
+       echo "Update of Bacula PostgreSQL tables 15 to 16 succeeded."
+       getVersion
+    else
+       echo "Update of Bacula PostgreSQL tables 15 to 116 failed."
+       exit 1
+    fi
+fi
+
+
 # For all versions, we need to create the Index on Media(PoolId/StorageId)
 # It may fail, but it's not a big problem
 psql -f - -d ${db_name} $* <<END-OF-DATA