3 # Shell script to update PostgreSQL tables from version 2.0.0 to 3.0.0 or higher
6 echo "This script will update a Bacula PostgreSQL database from version 10 to 11"
7 echo " which is needed to convert from Bacula version 2.0.0 to 3.0.x or higher"
12 if $bindir/psql -f - -d ${db_name} $* <<END-OF-DATA
14 -- The alter table operation can be faster with a big maintenance_work_mem
15 -- Uncomment and adapt this value to your environment
16 -- SET maintenance_work_mem = '1GB';
19 ALTER TABLE file ALTER fileid TYPE bigint ;
20 ALTER TABLE basefiles ALTER fileid TYPE bigint;
21 ALTER TABLE job ADD COLUMN readbytes bigint default 0;
22 ALTER TABLE media ADD COLUMN ActionOnPurge smallint default 0;
23 ALTER TABLE pool ADD COLUMN ActionOnPurge smallint default 0;
25 -- Create a table like Job for long term statistics
26 CREATE TABLE JobHisto (LIKE Job);
27 CREATE INDEX jobhisto_idx ON JobHisto ( starttime );
29 UPDATE Version SET VersionId=11;
32 -- If you have already this table, you can remove it with:
33 -- DROP TABLE JobHistory;
38 echo "Update of Bacula PostgreSQL tables succeeded."
40 echo "Update of Bacula PostgreSQL tables failed."