]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/update_postgresql_tables.in
Apply Eric's next-beta.patch that enables 64 bit FileIds and
[bacula/bacula] / bacula / src / cats / update_postgresql_tables.in
1 #!/bin/sh
2 #
3 # Shell script to update PostgreSQL tables from version 2.0.0 to 3.0.0 or higher
4 #
5 echo " "
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"
8 echo " "
9 bindir=@SQL_BINDIR@
10 db_name=@db_name@
11
12 if $bindir/psql -f - -d ${db_name} $* <<END-OF-DATA
13
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';
17
18 BEGIN;
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;
24
25 -- Create a table like Job for long term statistics
26 CREATE TABLE JobHisto (LIKE Job);
27 CREATE INDEX jobhisto_idx ON JobHisto ( starttime );
28
29 UPDATE Version SET VersionId=11;
30 COMMIT;
31
32 -- If you have already this table, you can remove it with:
33 -- DROP TABLE JobHistory;
34
35 -- vacuum analyse;
36 END-OF-DATA
37 then
38    echo "Update of Bacula PostgreSQL tables succeeded."
39 else
40    echo "Update of Bacula PostgreSQL tables failed."
41 fi
42 exit 0