]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Update catalog to version 1023
authorMichal Rakowski <michal.rakowski@baculasystems.com>
Thu, 15 Oct 2020 20:53:18 +0000 (22:53 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:57 +0000 (09:02 +0100)
bacula/src/cats/make_mysql_tables.in
bacula/src/cats/make_postgresql_tables.in
bacula/src/cats/make_sqlite3_tables.in
bacula/src/cats/update_mysql_tables.in
bacula/src/cats/update_postgresql_tables.in
bacula/src/cats/update_sqlite3_tables.in
bacula/updatedb/update_mysql_tables_1020_to_1021.in [new file with mode: 0644]
bacula/updatedb/update_mysql_tables_1021_to_1022.in
bacula/updatedb/update_mysql_tables_1022_to_1023.in [new file with mode: 0644]
bacula/updatedb/update_postgresql_tables_1022_to_1023.in [new file with mode: 0644]

index 9daf6a4f265c35e8bc892c6e7bcd2d90d5e479ae..c645d449c60cb1169df1582253fcfa9044330c61 100644 (file)
@@ -79,6 +79,7 @@ CREATE TABLE Object
 );
 
 create index object_jobid_idx on Object (JobId);
+create index object_type_idx on Object  (ObjectCategory(255));
 create index object_type_idx on Object  (ObjectType(255));
 create index object_name_idx on Object  (ObjectName(255));
 create index object_source_idx on Object  (ObjectSource(255));
@@ -548,7 +549,7 @@ CREATE TABLE Version (
    );
 
 -- Initialize Version
-INSERT INTO Version (VersionId) VALUES (1022);
+INSERT INTO Version (VersionId) VALUES (1023);
 
 END-OF-DATA
 then
index 27abc86ebd630a33391764f41899a6ca6f696a81..5d83cd9bf73b544966fb59487a7a9fccf1894388 100644 (file)
@@ -62,6 +62,7 @@ CREATE TABLE Object
 );
 
 create index object_jobid_idx on Object (JobId);
+create index object_category_idx on Object (ObjectCategory);
 create index object_type_idx on Object  (ObjectType);
 create index object_name_idx on Object  (ObjectName);
 create index object_source_idx on Object  (ObjectSource);
@@ -549,7 +550,7 @@ CREATE UNIQUE INDEX snapshot_idx ON Snapshot (Device text_pattern_ops,
                                              Volume text_pattern_ops,
                                              Name text_pattern_ops);
 
-INSERT INTO Version (VersionId) VALUES (1022);
+INSERT INTO Version (VersionId) VALUES (1023);
 
 -- Make sure we have appropriate permissions
 
index fef7125212f0a95d6d0e0beb15cb09bbdb4b3496..07d50a1857be10aa60598ef3800a971d24508638 100644 (file)
@@ -59,6 +59,7 @@ CREATE TABLE Object
 );
 
 create index object_jobid_idx on Object (JobId);
+create index object_category_idx on Object (ObjectCategory);
 create index object_type_idx on Object  (ObjectType);
 create index object_name_idx on Object  (ObjectName);
 create index object_source_idx on Object  (ObjectSource);
@@ -542,7 +543,7 @@ INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
    ('I', 'Incomplete Job',25);
 
 -- Initialize Version           
-INSERT INTO Version (VersionId) VALUES (1022);
+INSERT INTO Version (VersionId) VALUES (1023);
 
 PRAGMA default_cache_size = 100000;
 PRAGMA synchronous = NORMAL;
index 3178ac588dabb71a4776b2e3c6e2bd90a246c068..8bfd877b3661d03bf69f157ba407ef25918f19ec 100644 (file)
@@ -499,6 +499,8 @@ USE ${db_name};
 ALTER TABLE FileMedia ADD FileMediaId integer auto_increment primary key;
 ALTER TABLE JobHisto MODIFY COLUMN JobId int PRIMARY KEY AUTO_INCREMENT;
 ALTER TABLE Version MODIFY COLUMN VersionId int PRIMARY KEY;
+ALTER TABLE Object ADD ObjectCategory TINYBLOB NOT NULL;
+create index object_type_idx on Object  (ObjectCategory(255));
 UPDATE Version SET VersionId=1023;
 END-OF-DATA
     then
index 3f4a4b051debd5c931b0fa3215978688b28a3619..73aede30621d7172bc7d9741cba2137ec20b5ef9 100644 (file)
@@ -562,6 +562,24 @@ END-OF-DATA
     fi
 fi
 
+if [ "$DBVERSION" -eq 1022 ] ; then
+    if psql -f - -d ${db_name} $* <<END-OF-DATA
+begin;
+ALTER TABLE Object ADD COLUMN ObjectCategory text not null;
+create index object_category_idx on Object  (ObjectCategory);
+UPDATE Version SET VersionId=1023;
+commit;
+END-OF-DATA
+    then
+       echo "Update of Bacula PostgreSQL tables 1022 to 1023 succeeded."
+       getVersion
+    else
+       echo "Update of Bacula PostgreSQL tables 1022 to 1023 failed."
+       exit 1
+    fi
+fi
+
+
 #
 # For all versions, we need to create the Index on Media(PoolId/StorageId)
 # It may fail, but it's not a big problem
index 7f9e68836bf5424d4f6fb7ac1f2c08e17d60a879..41fefefb91438b421efa367b23fee18c98e562e4 100644 (file)
@@ -305,10 +305,27 @@ UPDATE Version SET VersionId=1022;
 commit;
 END-OF-DATA
     then
-       echo "Update of Bacula SQLite3 tables 1020 to 1021 succeeded."
+       echo "Update of Bacula SQLite3 tables 1021 to 1022 succeeded."
        getVersion
     else
-       echo "Update of Bacula SQLite3 tables 1020 to 1021 failed."
+       echo "Update of Bacula SQLite3 tables 1021 to 1022 failed."
+       exit 1
+    fi
+fi
+
+if [ "$DBVERSION" -eq 1022 ] ; then
+    if sqlite3 -f - -d ${db_name} $* <<END-OF-DATA
+begin;
+ALTER TABLE Object ADD COLUMN ObjectCategory text not null;
+create index object_category_idx on Object  (ObjectCategory);
+UPDATE Version SET VersionId=1023;
+commit;
+END-OF-DATA
+    then
+       echo "Update of Bacula SQLite3 tables 1022 to 1023 succeeded."
+       getVersion
+    else
+       echo "Update of Bacula SQLite3 tables 1022 to 1023 failed."
        exit 1
     fi
 fi
diff --git a/bacula/updatedb/update_mysql_tables_1020_to_1021.in b/bacula/updatedb/update_mysql_tables_1020_to_1021.in
new file mode 100644 (file)
index 0000000..4facb23
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Shell script to update MySQL
+#
+echo " "
+echo "This script will update a Bacula MySQL database from version 1020 to 1021"
+echo " which is needed to convert from Bacula version 10.2 to 10.4"
+echo " "
+bindir=@MYSQL_BINDIR@
+PATH="$bindir:$PATH"
+db_name=${db_name:-@db_name@}
+
+mysql $* -D ${db_name} -e "select VersionId from Version\G" >/tmp/$$
+DBVERSION=`sed -n -e 's/^VersionId: \(.*\)$/\1/p' /tmp/$$`
+if [ $DBVERSION != 1020 ] ; then
+   echo " "
+   echo "The existing database is version $DBVERSION !!"
+   echo "This script can only update an existing version 1020 database to version 1021."
+   echo "Error. Cannot upgrade this database."
+   echo " "
+   exit 1
+fi
+
+if mysql $* -f <<END-OF-DATA
+USE ${db_name};
+UPDATE Version SET VersionId=1021;
+ALTER TABLE File
+   MODIFY FileIndex INTEGER DEFAULT 0;
+ALTER TABLE RestoreObject
+   MODIFY FileIndex INTEGER DEFAULT 0;
+ALTER TABLE BaseFiles
+   MODIFY FileIndex INTEGER DEFAULT 0;
+
+-- If you switch to MySQL 5.7
+ALTER TABLE Device ALTER COLUMN CleaningDate DROP DEFAULT;
+ALTER TABLE Job    ALTER COLUMN SchedTime    DROP DEFAULT;
+ALTER TABLE Job    ALTER COLUMN StartTime    DROP DEFAULT;
+ALTER TABLE Job    ALTER COLUMN EndTime      DROP DEFAULT;
+ALTER TABLE Job    ALTER COLUMN RealEndTime  DROP DEFAULT;
+ALTER TABLE JobHisto ALTER COLUMN SchedTime  DROP DEFAULT;
+ALTER TABLE JobHisto ALTER COLUMN StartTime  DROP DEFAULT;
+ALTER TABLE JobHisto ALTER COLUMN EndTime    DROP DEFAULT;
+ALTER TABLE JobHisto ALTER COLUMN RealEndTime DROP DEFAULT;
+ALTER TABLE LocationLog ALTER COLUMN Date DROP DEFAULT;
+ALTER TABLE FileSet    ALTER COLUMN CreateTime DROP DEFAULT;
+ALTER TABLE Media      ALTER COLUMN FirstWritten DROP DEFAULT;
+ALTER TABLE Media      ALTER COLUMN LastWritten DROP DEFAULT;
+ALTER TABLE Media      ALTER COLUMN LabelDate DROP DEFAULT;
+ALTER TABLE Media      ALTER COLUMN InitialWrite DROP DEFAULT;
+ALTER TABLE Log        ALTER COLUMN Time DROP DEFAULT;
+
+END-OF-DATA
+then
+   echo "Update of Bacula MySQL tables succeeded."
+else
+   echo "Update of Bacula MySQL tables failed."
+fi
+exit 0
index f71bb503322966df5f6c7ad0ddb3d31db3436752..435f33db27f24b383ba4ae360c36e5212bdb94e5 100644 (file)
@@ -14,10 +14,10 @@ db_name=${db_name:-@db_name@}
 
 mysql $* -D ${db_name} -e "select VersionId from Version\G" >/tmp/$$
 DBVERSION=`sed -n -e 's/^VersionId: \(.*\)$/\1/p' /tmp/$$`
-if [ $DBVERSION != 1020 ] ; then
+if [ $DBVERSION != 1021 ] ; then
    echo " "
    echo "The existing database is version $DBVERSION !!"
-   echo "This script can only update an existing version 1019 database to version 1021."
+   echo "This script can only update an existing version 1021 database to version 1022."
    echo "Error. Cannot upgrade this database."
    echo " "
    exit 1
diff --git a/bacula/updatedb/update_mysql_tables_1022_to_1023.in b/bacula/updatedb/update_mysql_tables_1022_to_1023.in
new file mode 100644 (file)
index 0000000..83599c0
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Shell script to update MySQL
+#
+echo " "
+echo "This script will update a Bacula MySQL database from version 1022 to 1023"
+echo " "
+bindir=@MYSQL_BINDIR@
+PATH="$bindir:$PATH"
+db_name=${db_name:-@db_name@}
+
+mysql $* -D ${db_name} -e "select VersionId from Version\G" >/tmp/$$
+DBVERSION=`sed -n -e 's/^VersionId: \(.*\)$/\1/p' /tmp/$$`
+if [ $DBVERSION != 1022 ] ; then
+   echo " "
+   echo "The existing database is version $DBVERSION !!"
+   echo "This script can only update an existing version 1022 database to version 1023."
+   echo "Error. Cannot upgrade this database."
+   echo " "
+   exit 1
+fi
+
+if mysql $* -f <<END-OF-DATA
+USE ${db_name};
+ALTER TABLE FileMedia ADD FileMediaId integer auto_increment primary key;
+ALTER TABLE JobHisto MODIFY COLUMN JobId int PRIMARY KEY AUTO_INCREMENT;
+ALTER TABLE Version MODIFY COLUMN VersionId int PRIMARY KEY;
+ALTER TABLE Object ADD ObjectCategory TINYBLOB NOT NULL;
+create index object_type_idx on Object  (ObjectType(255));
+UPDATE Version SET VersionId=1023;
+END-OF-DATA
+then
+   echo "Update of Bacula MySQL tables succeeded."
+else
+   echo "Update of Bacula MySQL tables failed."
+fi
+exit 0
diff --git a/bacula/updatedb/update_postgresql_tables_1022_to_1023.in b/bacula/updatedb/update_postgresql_tables_1022_to_1023.in
new file mode 100644 (file)
index 0000000..faf04bf
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+#
+echo " "
+echo "This script will update a Bacula PostgreSQL database from version 1020 to 1021"
+echo " "
+
+bindir=@POSTGRESQL_BINDIR@
+PATH="$bindir:$PATH"
+db_name=${db_name:-@db_name@}
+
+DBVERSION=`psql -d ${db_name} -t --pset format=unaligned -c "select VersionId from Version" $*`
+if [ $DBVERSION != 1022 ] ; then
+   echo " "
+   echo "The existing database is version $DBVERSION !!"
+   echo "This script can only update an existing version 1022 database to version 1023."
+   echo "Error. Cannot upgrade this database."
+   echo " "
+   exit 1
+fi
+
+if psql -f - -d ${db_name} $* <<END-OF-DATA
+begin;
+ALTER TABLE Object ADD COLUMN ObjectCategory text not null;
+create index object_category_idx on Object  (ObjectCategory);
+UPDATE Version SET VersionId=1023;
+commit;
+END-OF-DATA
+then
+   echo "Update of Bacula PostgreSQL tables succeeded."
+else
+   echo "Update of Bacula PostgreSQL tables failed."
+fi
+
+exit 0