]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
cats: Update postgresql upgrade procedure
authorEric Bollengier <eric@baculasystems.com>
Fri, 30 Sep 2022 18:57:11 +0000 (20:57 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:59 +0000 (13:56 +0200)
bacula/src/cats/update_postgresql_tables.in
bacula/updatedb/update_postgresql_tables_1025_to_1026.in

index 6e290e6723c0a72089134748d5ac5b0d0a7c61c0..0bca86b0ec9fbcc7be1a701a6b117d4802b5cb28 100644 (file)
@@ -717,7 +717,50 @@ fi
 if [ "$DBVERSION" -eq 1025 ] ; then
     if psql -f - -d ${db_name} $* <<END-OF-DATA
 begin;
+CREATE TABLE MalwareMD5
+(
+    MD5     char(22)    -- Same as File
+);
+CREATE INDEX malwaremd5_idx on MalwareMD5 (MD5);
+
+CREATE TABLE MalwareSHA256
+(
+    MD5     char(65)    -- Same as File
+);
+CREATE INDEX malwaresha256_idx on MalwareSHA256 (MD5);
+
+CREATE TABLE FileEvents 
+(
+   Id   bigserial,
+   Time timestamp without time zone default NOW(), -- Time of the detection
+   SourceJobId   int,        -- Can be the Verify job id for example, or the jobid during a restore/backup
+   JobId         int,        -- JobId where the file was found. Used for pruning
+   FileIndex     int,        -- File reference
+   Type          char,       -- Event type (antivirus, malware scanning (M), lost file)
+   Description   text,       -- Description of the event
+   Severity      int,        -- level of severity. (0 OK, 100 Important)
+   Source        text        -- Information about the source of the event
+);
+
+CREATE INDEX FileEvents_jobid_idx ON FileEvents (JobId, FileIndex);
+CREATE INDEX FileEvents_sourcejobid_idx ON FileEvents (SourceJobId);
 CREATE INDEX meta_emailid on MetaEmail (EmailId);
+
+ALTER TABLE Object ADD COLUMN FileIndex    integer  not null default 0;
+ALTER TABLE Job ADD COLUMN RealStartTime     timestamp   without time zone;
+ALTER TABLE Job ADD COLUMN isVirtualFull     smallint    default 0;
+ALTER TABLE Job ADD COLUMN CompressRatio     float       default 0;
+ALTER TABLE Job ADD COLUMN Rate              float       default 0;
+ALTER TABLE Job ADD COLUMN LastReadStorageId integer     default 0;
+ALTER TABLE Job ADD COLUMN LastReadDevice    text        default '';
+ALTER TABLE Job ADD COLUMN WriteStorageId    integer     default 0;
+ALTER TABLE Job ADD COLUMN WriteDevice       text        default ''
+ALTER TABLE Job ADD COLUMN StatusInfo        text        default '';
+ATLER TABLE Job ADD COLUMN Encrypted         int         default 0;
+
+ALTER TABLE Media ADD COLUMN Worm              smallint    default 0;
+ALTER TABLE Media ADD COLUMN IsWorm            smallint    default 0;
+
 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;
index e2252ef25f82935a3668139f20dc655831eb30e7..e46cf105b11b474c15e18bca4863f9435e6d1940 100644 (file)
@@ -24,7 +24,50 @@ fi
 
 if psql -f - -d ${db_name} $* <<END-OF-DATA
 begin;
+CREATE TABLE MalwareMD5
+(
+    MD5     char(22)    -- Same as File
+);
+CREATE INDEX malwaremd5_idx on MalwareMD5 (MD5);
+
+CREATE TABLE MalwareSHA256
+(
+    MD5     char(65)    -- Same as File
+);
+CREATE INDEX malwaresha256_idx on MalwareSHA256 (MD5);
+
+CREATE TABLE FileEvents 
+(
+   Id   bigserial,
+   Time timestamp without time zone default NOW(), -- Time of the detection
+   SourceJobId   int,        -- Can be the Verify job id for example, or the jobid during a restore/backup
+   JobId         int,        -- JobId where the file was found. Used for pruning
+   FileIndex     int,        -- File reference
+   Type          char,       -- Event type (antivirus, malware scanning (M), lost file)
+   Description   text,       -- Description of the event
+   Severity      int,        -- level of severity. (0 OK, 100 Important)
+   Source        text        -- Information about the source of the event
+);
+
+CREATE INDEX FileEvents_jobid_idx ON FileEvents (JobId, FileIndex);
+CREATE INDEX FileEvents_sourcejobid_idx ON FileEvents (SourceJobId);
 CREATE INDEX meta_emailid on MetaEmail (EmailId);
+
+ALTER TABLE Object ADD COLUMN FileIndex    integer  not null default 0;
+ALTER TABLE Job ADD COLUMN RealStartTime     timestamp   without time zone;
+ALTER TABLE Job ADD COLUMN isVirtualFull     smallint    default 0;
+ALTER TABLE Job ADD COLUMN CompressRatio     float       default 0;
+ALTER TABLE Job ADD COLUMN Rate              float       default 0;
+ALTER TABLE Job ADD COLUMN LastReadStorageId integer     default 0;
+ALTER TABLE Job ADD COLUMN LastReadDevice    text        default '';
+ALTER TABLE Job ADD COLUMN WriteStorageId    integer     default 0;
+ALTER TABLE Job ADD COLUMN WriteDevice       text        default ''
+ALTER TABLE Job ADD COLUMN StatusInfo        text        default '';
+ATLER TABLE Job ADD COLUMN Encrypted         int         default 0;
+
+ALTER TABLE Media ADD COLUMN Worm              smallint    default 0;
+ALTER TABLE Media ADD COLUMN IsWorm            smallint    default 0;
+
 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;