]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/update_postgresql_tables.in
Update database scripts to include CDImages table for bimagemgr.
[bacula/bacula] / bacula / src / cats / update_postgresql_tables.in
1 #!/bin/sh
2 #
3 # Shell script to update PostgreSQL tables from version 1.34 to 1.35.5
4 #
5 echo " "
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."
9 echo " "
10 bindir=@SQL_BINDIR@
11
12 if $bindir/psql $* -f - <<END-OF-DATA
13 \c bacula
14
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;
21
22 UPDATE Filename SET Name='' WHERE Name=' ';
23
24 ALTER TABLE file ALTER COLUMN filenameid SET integer;
25
26 DELETE FROM Version;
27 INSERT INTO Version (VersionId) VALUES (8);
28
29 create index file_jobid_idx on file (jobid);
30 create index file_pathid_idx on file(pathid);
31 create index file_filenameid_idx on file(filenameid);
32 create index file_jpfid_idx on file (jobid, pathid, filenameid);
33
34 create table CDImages 
35 (
36    MediaId integer not null,
37    LastBurn timestamp without time zone not null,
38    primary key (MediaId)
39 );
40
41 END-OF-DATA
42 then
43    echo "Update of Bacula PostgreSQL tables succeeded."
44 else
45    echo "Update of Bacula PostgreSQL tables failed."
46 fi
47 exit 0