]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
update catalog version to 1026
authorEric Bollengier <eric@baculasystems.com>
Tue, 12 Apr 2022 07:43:59 +0000 (09:43 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:59 +0000 (13:56 +0200)
bacula/src/cats/cats.h
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/updatedb/update_mysql_tables_1025_to_1026.in [new file with mode: 0644]
bacula/updatedb/update_postgresql_tables_1025_to_1026.in [new file with mode: 0644]

index 7d03da3158c0da40f80977a0410c9394ccd0f49e..c6239bcbd2d0857e8e31ba2040852c5378f736d6 100644 (file)
@@ -48,7 +48,7 @@
  */
 
 /* Current database version number for all drivers */
-#define BDB_VERSION 1025
+#define BDB_VERSION 1026
 
 typedef void (DB_LIST_HANDLER)(void *, const char *);
 typedef int (DB_RESULT_HANDLER)(void *, int, char **);
index 3cc11ada278ef86c2e46c9f4333ed5903debf657..137b5f0a4af2e85427f7622c752773a8667727bf 100644 (file)
@@ -66,6 +66,7 @@ CREATE FULLTEXT INDEX meta_emailsubjectbody ON MetaEmail
        (EmailSubject, EmailBodyPreview, EmailTo, EmailCc, EmailFrom);
 CREATE INDEX meta_emailowner ON MetaEmail (EmailTenant(255), EmailOwner(255));
 CREATE INDEX meta_emailtime on MetaEmail (EmailTime);
+CREATE INDEX meta_emailid on MetaEmail (EmailId);
 CREATE INDEX meta_emailtags on MetaEmail (EmailTags(255));
 CREATE INDEX meta_emailfoldername on MetaEmail (EmailFolderName(255));
 CREATE INDEX meta_emailconversationid on MetaEmail (EmailConversationId(255));
@@ -619,7 +620,7 @@ CREATE TABLE Version (
    );
 
 -- Initialize Version
-INSERT INTO Version (VersionId) VALUES (1025);
+INSERT INTO Version (VersionId) VALUES (1026);
 
 END-OF-DATA
 then
index 6c17237443ba6f603f41e09771661efabc619ca1..60570b72dfacf1bb349f1898cbb93f529fc64dad 100644 (file)
@@ -62,6 +62,7 @@ end \$\$;
 
 CREATE INDEX meta_emailowner on MetaEmail (EmailTenant, EmailOwner);
 CREATE INDEX meta_emailtime on MetaEmail (EmailTime);
+CREATE INDEX meta_emailid on MetaEmail (EmailId);
 CREATE INDEX meta_emailtags on MetaEmail (EmailTags);
 CREATE INDEX meta_emailfoldername on MetaEmail (EmailFolderName);
 -- CREATE INDEX meta_emailsender on MetaEmail (EmailSender);
@@ -645,7 +646,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 (1025);
+INSERT INTO Version (VersionId) VALUES (1026);
 
 
 COMMIT;
index c1e2afe5d17231725ff90835d097c6be3bab2caa..eafb1007c891e68bf7bc6f5626c3c8a7526b0d57 100644 (file)
@@ -42,6 +42,7 @@ CREATE TABLE MetaEmail
 
 CREATE INDEX meta_emailowner on MetaEmail (EmailTenant, EmailOwner);
 CREATE INDEX meta_emailtime on MetaEmail (EmailTime);
+CREATE INDEX meta_emailid on MetaEmail (EmailId);
 CREATE INDEX meta_emailtags on MetaEmail (EmailTags);
 CREATE INDEX meta_emailfoldername on MetaEmail (EmailFolderName);
 -- CREATE INDEX meta_emailsender on MetaEmail (EmailSender);
@@ -617,7 +618,7 @@ INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
    ('W', 'Terminated normally with warnings',25);
 
 -- Initialize Version           
-INSERT INTO Version (VersionId) VALUES (1025);
+INSERT INTO Version (VersionId) VALUES (1026);
 
 PRAGMA default_cache_size = 100000;
 PRAGMA synchronous = NORMAL;
index b8f6172ff2f2785d8a114d399c74ab69d65b3b10..716e5047550f51678220082cc10d3985210c6897 100644 (file)
@@ -6,8 +6,8 @@
 # Shell script to update MySQL tables to Bacula version 15.0.x
 #
 
-OLDVERSION=1024
-NEWVERSION=1025
+OLDVERSION=1025
+NEWVERSION=1026
 
 echo " "
 echo "This script will update a Bacula MySQL database"
@@ -637,7 +637,8 @@ INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
 ALTER TABLE RestoreObject MODIFY ObjectName MEDIUMBLOB;
 ALTER TABLE RestoreObject MODIFY PluginName BLOB;
 ALTER TABLE Object MODIFY PluginName BLOB;
-
+INSERT INTO Events (EventsCode, EventsType, EventsTime, EventsDaemon, EventsSource, EventsRef, EventsText) VALUES
+  ('DU0001', 'catalog_update', NOW(), '*SHELL*', 'update_bacula_tables', 'pid$$', 'Catalog schema was updated to 1025');
 UPDATE Version SET VersionId=1025;
 END-OF-DATA
     then
@@ -649,4 +650,22 @@ END-OF-DATA
     fi
 fi
 
+
+if [ "$DBVERSION" -eq 1025 ] ; then
+    if mysql $* -f  <<END-OF-DATA
+USE ${db_name};
+CREATE INDEX meta_emailid on MetaEmail (EmailId);
+INSERT INTO Events (EventsCode, EventsType, EventsTime, EventsDaemon, EventsSource, EventsRef, EventsText) VALUES
+  ('DU0001', 'catalog_update', NOW(), '*SHELL*', 'update_bacula_tables', 'pid$$', 'Catalog schema was updated to 1026');
+UPDATE Version SET VersionId=1026;
+END-OF-DATA
+    then
+        echo "Update of Bacula MySQL tables 1025 to 1026 succeeded."
+        getVersion
+    else
+        echo "Update of Bacula MySQL tables 1025 to 1026 failed."
+        exit 1
+    fi
+fi
+
 exit 0
index 85d60e284c6e20efe1d850263cf436833b5217cd..6e290e6723c0a72089134748d5ac5b0d0a7c61c0 100644 (file)
@@ -4,8 +4,8 @@
 # License: BSD 2-Clause; see file LICENSE-FOSS
 #
 
-OLDVERSION=1024
-NEWVERSION=1025
+OLDVERSION=1025
+NEWVERSION=1026
 
 echo " "
 echo "This script will update a Bacula PostgreSQL database"
@@ -699,7 +699,8 @@ INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
    ('q', 'Queued waiting for device',15);
 INSERT INTO Status (JobStatus,JobStatusLong,Severity) VALUES
    ('W', 'Terminated normally with warnings',25);
-
+INSERT INTO Events (EventsCode, EventsType, EventsTime, EventsDaemon, EventsSource, EventsRef, EventsText) VALUES
+  ('DU0001', 'catalog_update', NOW(), '*SHELL*', 'update_bacula_tables', 'pid$$', 'Catalog schema was updated to 1025');
 UPDATE Version SET VersionId=1025;
 commit;
 END-OF-DATA
@@ -712,6 +713,25 @@ END-OF-DATA
     fi
 fi
 
+
+if [ "$DBVERSION" -eq 1025 ] ; then
+    if psql -f - -d ${db_name} $* <<END-OF-DATA
+begin;
+CREATE INDEX meta_emailid on MetaEmail (EmailId);
+INSERT INTO Events (EventsCode, EventsType, EventsTime, EventsDaemon, EventsSource, EventsRef, EventsText) VALUES
+  ('DU0001', 'catalog_update', NOW(), '*SHELL*', 'update_bacula_tables', 'pid$$', 'Catalog schema was updated to 1026');
+UPDATE Version SET VersionId=1026;
+commit;
+END-OF-DATA
+    then
+       echo "Update of Bacula PostgreSQL tables 1025 to 1026 succeeded."
+       getVersion
+    else
+       echo "Update of Bacula PostgreSQL tables 1025 to 1026 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
diff --git a/bacula/updatedb/update_mysql_tables_1025_to_1026.in b/bacula/updatedb/update_mysql_tables_1025_to_1026.in
new file mode 100644 (file)
index 0000000..8d2ba76
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2022 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 1025 to 1026"
+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 != 1024 ] ; then
+   echo " "
+   echo "The existing database is version $DBVERSION !!"
+   echo "This script can only update an existing version 1025 database to version 1026."
+   echo "Error. Cannot upgrade this database."
+   echo " "
+   exit 1
+fi
+
+if mysql $* -f  <<END-OF-DATA
+USE ${db_name};
+CREATE INDEX meta_emailid on MetaEmail (EmailId);
+INSERT INTO Events (EventsCode, EventsType, EventsTime, EventsDaemon, EventsSource, EventsRef, EventsText) VALUES
+  ('DU0001', 'catalog_update', NOW(), '*SHELL*', 'update_bacula_tables', 'pid$$', 'Catalog schema was updated to 1025');
+
+UPDATE Version SET VersionId=1026;
+END-OF-DATA
+then
+   echo "Update of Bacula MySQL tables 1025 to 1026 succeeded."
+   getVersion
+else
+   echo "Update of Bacula MySQL tables 1025 to 1026 failed."
+   exit 1
+fi
+
+exit 0
diff --git a/bacula/updatedb/update_postgresql_tables_1025_to_1026.in b/bacula/updatedb/update_postgresql_tables_1025_to_1026.in
new file mode 100644 (file)
index 0000000..e2252ef
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2022 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+#
+echo " "
+echo "This script will update a Bacula PostgreSQL database from version 1025 to 1026"
+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 != 1024 ] ; then
+   echo " "
+   echo "The existing database is version $DBVERSION !!"
+   echo "This script can only update an existing version 1025 database to version 1026."
+   echo "Error. Cannot upgrade this database."
+   echo " "
+   exit 1
+fi
+
+if psql -f - -d ${db_name} $* <<END-OF-DATA
+begin;
+CREATE INDEX meta_emailid on MetaEmail (EmailId);
+INSERT INTO Events (EventsCode, EventsType, EventsTime, EventsDaemon, EventsSource, EventsRef, EventsText) VALUES
+  ('DU0001', 'catalog_update', NOW(), '*SHELL*', 'update_bacula_tables', 'pid$$', 'Catalog schema was updated to 1026');
+UPDATE Version SET VersionId=1026;
+commit;
+END-OF-DATA
+then
+   echo "Update of Bacula PostgreSQL tables 1025 to 1026 succeeded."
+else
+   echo "Update of Bacula PostgreSQL tables 1025 to 1026 failed."
+   exit 1
+fi
+
+exit 0