);
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));
);
-- Initialize Version
-INSERT INTO Version (VersionId) VALUES (1022);
+INSERT INTO Version (VersionId) VALUES (1023);
END-OF-DATA
then
);
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);
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
);
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);
('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;
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
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
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
--- /dev/null
+#!/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
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
--- /dev/null
+#!/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
--- /dev/null
+#!/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