3 # Shell script to update PostgreSQL tables from version 1.34 to 1.35.5
6 echo "This script will update a Bacula PostgreSQL database from version 7 to 8"
7 echo "Depending on the size of your database,"
8 echo "this script may take several minutes to run."
12 if $bindir/psql $* -f - <<END-OF-DATA
15 ALTER TABLE media ADD COLUMN EndFile integer;
16 UPDATE media SET EndFile=0;
17 ALTER TABLE media ALTER COLUMN EndFile SET NOT NULL;
18 ALTER TABLE media ADD COLUMN EndBlock integer;
19 UPDATE media SET EndBlock=0;
20 ALTER TABLE media ALTER COLUMN EndBlock SET NOT NULL;
22 UPDATE Filename SET Name='' WHERE Name=' ';
24 alter table file rename column filenameid to filenameidold;
25 alter table file add column filenameid integer;
26 update file set filenameid = filenameidold;
27 alter table file alter column filenameid set not null;
28 alter table file drop column filenameidold;
31 INSERT INTO Version (VersionId) VALUES (8);
33 create index file_jobid_idx on file (jobid);
34 create index file_pathid_idx on file(pathid);
35 create index file_filenameid_idx on file(filenameid);
36 create index file_jpfid_idx on file (jobid, pathid, filenameid);
40 MediaId integer not null,
41 LastBurn timestamp without time zone not null,
49 echo "Update of Bacula PostgreSQL tables succeeded."
51 echo "Update of Bacula PostgreSQL tables failed."