]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/update_sqlite3_tables.in
Remove Ingres and DBI backends
[bacula/bacula] / bacula / src / cats / update_sqlite3_tables.in
index d8bef9626e1e4b2761a81d37c185296bfd31635d..1b8ae4f67bbc9fc38838e9a243688f39d0829145 100644 (file)
@@ -1,68 +1,54 @@
 #!/bin/sh
 #
-# This script is needed to convert from Bacula Enterprise 2.6 to 4.0 or
-# Standard version 3.0 to 5.0
+# Shell script to update MySQL tables from Bacula Enterprise version 2.6.x to 4.0.x
+#  or Bacula Community version 5.0.x to 5.2.x
 #
 echo " "
-echo "This script will update a Bacula SQLite database from version 11 to 12"
-echo " which is needed to convert from Bacula Enterprise 2.6 to 4.0 or "
-echo " Standard version 3.0 to 5.0"
-echo "Depending on the size of your database,"
-echo "this script may take several minutes to run."
+echo "This script will update a Bacula MySQL database from version 12 to 13"
+echo " which is needed to convert from Bacula Enterprise version 2.6.x to 4.0.x"
+echo " or Bacula Community version 5.0.x to 5.2.x"
 echo " "
 
-bindir=@SQL_BINDIR@
+bindir=@SQLITE_BINDIR@
 PATH="$bindir:$PATH"
 cd @working_dir@
-sqlite=@DB_TYPE@
 db_name=@db_name@
 
-${sqlite} $* ${db_name}.db <<END-OF-DATA
+DBVERSION=`sqlite3 ${db_name}.db <<END
+select VersionId from Version;
+END
+`
+if [ $DBVERSION != 12 ] ; then
+   echo " "
+   echo "The existing database is version $DBVERSION !!"
+   echo "This script can only update an existing version 12 database to version 13."
+   echo "Error. Cannot upgrade this database."
+   echo " "
+   exit 1
+fi
+
+sqlite3 $* ${db_name}.db <<END-OF-DATA
 BEGIN;
-ALTER TABLE Job ADD COLUMN HasCache TINYINT DEFAULT 0;
-ALTER TABLE Job ADD COLUMN Reviewed TINYINT DEFAULT 0;
-ALTER TABLE Job ADD COLUMN Comment TEXT;
-ALTER TABLE JobHisto ADD COLUMN HasCache TINYINT DEFAULT 0;
-ALTER TABLE JobHisto ADD COLUMN Reviewed TINYINT DEFAULT 0;
-ALTER TABLE JobHisto ADD COLUMN Comment TEXT;
 
-ALTER TABLE Status ADD COLUMN Severity int;
-UPDATE Status SET Severity = 15;
-UPDATE Status SET Severity = 100 where JobStatus = 'f';
-UPDATE Status SET Severity = 90 where JobStatus = 'A';
-UPDATE Status SET Severity = 10 where JobStatus = 'T';
-UPDATE Status SET Severity = 20 where JobStatus = 'e';
-UPDATE Status SET Severity = 25 where JobStatus = 'E';
-
-CREATE TABLE PathHierarchy
-(
-     PathId integer NOT NULL,
-     PPathId integer NOT NULL,
-     CONSTRAINT pathhierarchy_pkey PRIMARY KEY (PathId)
-);
-
-CREATE INDEX pathhierarchy_ppathid 
-          ON PathHierarchy (PPathId);
-
-CREATE TABLE PathVisibility
-(
-      PathId integer NOT NULL,
-      JobId integer NOT NULL,
-      Size int8 DEFAULT 0,
-      Files int4 DEFAULT 0,
-      CONSTRAINT pathvisibility_pkey PRIMARY KEY (JobId, PathId)
-);
-
-CREATE INDEX pathvisibility_jobid
-          ON PathVisibility (JobId);
-
-CREATE INDEX basefiles_jobid_idx ON BaseFiles ( JobId );
-
-UPDATE Version SET VersionId=12;
+CREATE TABLE RestoreObject (
+   RestoreObjectId INTEGER,
+   ObjectName TEXT DEFAULT '',
+   RestoreObject TEXT DEFAULT '',
+   PluginName TEXT DEFAULT '',
+   ObjectLength INTEGER DEFAULT 0,
+   ObjectFullLength INTEGER DEFAULT 0,
+   ObjectIndex INTEGER DEFAULT 0,
+   ObjectType INTEGER DEFAULT 0,
+   FileIndex INTEGER UNSIGNED DEFAULT 0,
+   ObejctCompression INTEGER DEFAULT 0,
+   JobId INTEGER UNSIGNED REFERENCES Job NOT NULL,
+   PRIMARY KEY(RestoreObjectId)
+   );
+CREATE INDEX restore_jobid_idx ON RestoreObject (JobId);
+
+ALTER TABLE File ADD COLUMN DeltaSeq smallint default 0;
+
+UPDATE Version SET VersionId=14;
 COMMIT;
 
-DROP INDEX inx4;
-DROP INDEX inx9; -- can generate errors
-CREATE INDEX file_jpf_idx ON File (JobId, PathId, FilenameId);
-
 END-OF-DATA