]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/update_postgresql_tables.in
20Feb06
[bacula/bacula] / bacula / src / cats / update_postgresql_tables.in
1 #!/bin/sh
2 #
3 # Shell script to update PostgreSQL tables from version 1.38 to 1.39
4 #
5 echo " "
6 echo "This script will update a Bacula PostgreSQL database from version 9 to 9"
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 - -d bacula $* <<END-OF-DATA
13
14 ALTER TABLE media ADD COLUMN DeviceId integer;
15 UPDATE media SET DeviceId=0;
16 ALTER TABLE media ADD COLUMN MediaTypeId integer;
17 UPDATE media SET MediaTypeId=0;
18 ALTER TABLE media ADD COLUMN LocationId integer;
19 UPDATE media SET LocationId=0;
20
21
22 CREATE TABLE MAC (
23     JobId             serial      not null,
24     OriginalJobId     serial      not null,
25     JobType           char(1)     not null,
26     JobLevel          char(1)     not null,
27     SchedTime         timestamp   without time zone not null,
28     StartTime         timestamp   without time zone,
29     EndTime           timestamp   without time zone,
30     JobTDate          bigint      not null,
31     primary key (JobId)
32 );
33
34 CREATE TABLE Location (
35    LocationId SERIAL,
36    Location TEXT NOT NULL,
37    PRIMARY KEY(LocationId)
38    );
39
40
41 INSERT INTO version (versionId) VALUES (9);
42
43 vacuum;
44
45 END-OF-DATA
46 then
47    echo "Update of Bacula PostgreSQL tables succeeded."
48 else
49    echo "Update of Bacula PostgreSQL tables failed."
50 fi
51 exit 0