db_name=@db_name@
$bindir/psql -f - -d ${db_name} $* <<END-OF-DATA 1>/dev/null 2>/dev/null
+drop table if exists MalwareMD5;
+drop table if exists MalwareSHA256;
+drop table if exists FileEvents;
drop table if exists MetaEmail;
drop table if exists MetaAttachment;
drop table if exists TagJob;
psql -f - -d ${db_name} $* <<END-OF-DATA
BEGIN;
+CREATE TABLE MalwareMD5
+(
+ MD5 char(22)
+);
+CREATE INDEX malwaremd5_idx on MalwareMD5 (MD5);
+
+CREATE TABLE MalwareSHA256
+(
+ MD5 char(65)
+);
+CREATE INDEX malwaresha256_idx on Malwaresha256 (MD5);
+
+CREATE TABLE FileEvents
+(
+ Id bigserial,
+ Time timestamp 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);
+
-- --------------------------------------------------------------
-- MetaData Index
CREATE TABLE MetaEmail
(
- EmailTenant text,
- EmailOwner text,
- EmailId text,
- EmailTime timestamp without time zone,
+ EmailTenant text, -- Tenant used to get the email
+ EmailOwner text, -- Email address
+ EmailId text, -- EmailId generated by the software
+ EmailTime timestamp without time zone,
EmailTags text,
EmailSubject text,
EmailFolderName text,
EmailFrom text,
EmailTo text,
- EmailCc text,
+ EmailCc text,
EmailInternetMessageId text, -- no index
EmailBodyPreview text,
EmailImportance text,
EmailIsRead smallint,
EmailIsDraft smallint,
EmailHasAttachment smallint,
- EmailSize integer,
- Plugin text,
- FileIndex int,
- JobId int
+ EmailSize integer,
+ Plugin text,
+ FileIndex int,
+ JobId int
);
-- Need to add postgresql-contrib to the dependency list