3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
6 # Shell script to update PostgreSQL tables from version 2.0.0 to 3.0.0 or higher
9 echo "This script will update a Bacula PostgreSQL database from version 10 to 11"
10 echo " which is needed to convert from Bacula version 2.0.0 to 3.0.x or higher"
12 bindir=@POSTGRESQL_BINDIR@
14 db_name=${db_name:-@db_name@}
16 if psql -f - -d ${db_name} $* <<END-OF-DATA
17 -- The alter table operation can be faster with a big maintenance_work_mem
18 -- Uncomment and adapt this value to your environment
19 -- SET maintenance_work_mem = '1GB';
22 ALTER TABLE file ALTER fileid TYPE bigint ;
23 ALTER TABLE basefiles ALTER fileid TYPE bigint;
24 ALTER TABLE job ADD COLUMN readbytes bigint default 0;
25 ALTER TABLE media ADD COLUMN ActionOnPurge smallint default 0;
26 ALTER TABLE pool ADD COLUMN ActionOnPurge smallint default 0;
28 -- Create a table like Job for long term statistics
29 CREATE TABLE JobHisto (LIKE Job);
30 CREATE INDEX jobhisto_idx ON JobHisto ( starttime );
32 UPDATE Version SET VersionId=11;
35 -- If you have already this table, you can remove it with:
36 -- DROP TABLE JobHistory;
41 echo "Update of Bacula PostgreSQL tables succeeded."
43 echo "Update of Bacula PostgreSQL tables failed."