3 # Shell script to update MySQL tables from Bacula Enterprise 2.6 to 4.0 or
4 # Standard version 3.0 to 5.0
7 echo "This script will update a Bacula MySQL database from version 11 to 12"
8 echo " which is needed to convert from Bacula Enterprise 2.6 to 4.0 or "
9 echo " Standard version 3.0 to 5.0"
15 if mysql $* -f <<END-OF-DATA
18 ALTER TABLE JobMedia DROP Stripe ;
19 ALTER TABLE JobMedia DROP Copy ;
20 ALTER TABLE Job ADD COLUMN HasCache tinyint default 0 after HasBase;
21 ALTER TABLE Job ADD COLUMN Reviewed tinyint default 0 after HasCache;
22 ALTER TABLE Job ADD COLUMN Comment BLOB AFTER Reviewed;
23 ALTER TABLE JobHisto ADD COLUMN HasCache tinyint default 0 after HasBase;
24 ALTER TABLE JobHisto ADD COLUMN Reviewed tinyint default 0 after HasCache;
25 ALTER TABLE JobHisto ADD COLUMN Comment BLOB AFTER Reviewed;
27 ALTER TABLE Status ADD COLUMN Severity int;
28 UPDATE Status SET Severity = 15;
29 UPDATE Status SET Severity = 100 where JobStatus = 'f';
30 UPDATE Status SET Severity = 90 where JobStatus = 'A';
31 UPDATE Status SET Severity = 10 where JobStatus = 'T';
32 UPDATE Status SET Severity = 20 where JobStatus = 'e';
33 UPDATE Status SET Severity = 25 where JobStatus = 'E';
35 CREATE TABLE PathHierarchy
37 PathId integer NOT NULL,
38 PPathId integer NOT NULL,
39 CONSTRAINT pathhierarchy_pkey PRIMARY KEY (PathId)
42 CREATE INDEX pathhierarchy_ppathid
43 ON PathHierarchy (PPathId);
45 CREATE TABLE PathVisibility
47 PathId integer NOT NULL,
48 JobId integer NOT NULL,
51 CONSTRAINT pathvisibility_pkey PRIMARY KEY (JobId, PathId)
53 CREATE INDEX pathvisibility_jobid
54 ON PathVisibility (JobId);
56 CREATE INDEX basefiles_jobid_idx ON BaseFiles ( JobId );
59 INSERT INTO Version (VersionId) VALUES (12);
63 echo "Update of Bacula MySQL tables succeeded."
65 echo "Update of Bacula MySQL tables failed."