CREATE TABLE `def_document` (
`Docname` char(255) NOT NULL,
`Package` char(255) NOT NULL DEFAULT '',
`Group` char(255) NOT NULL DEFAULT '',
`Module` char(255) DEFAULT NULL,
`Project` char(255) DEFAULT '',
`DocType` char(20) NOT NULL DEFAULT 'JPG',
`Base` char(255) DEFAULT '',
`Folder` char(255) DEFAULT '',
`DocumentRoot` char(255) DEFAULT '',
`DocX` int(11) DEFAULT 0,
`DocY` int(11) DEFAULT 0,
`Level` int(11) DEFAULT 0,
`DocDescription` text DEFAULT NULL,
`Glyph` char(255) DEFAULT 'fa fa-cloud',
`MetaEnvelope` char(255) DEFAULT 'document',
`XmContainer` char(255) DEFAULT 'meta',
`ContextTable` char(255) DEFAULT '',
`ContextField` char(255) DEFAULT '',
`ContextField2` char(255) DEFAULT '',
`Portfolio` char(255) DEFAULT NULL,
`SourceMask` char(255) DEFAULT '',
`SourceFolder` char(255) DEFAULT '',
`SourceMaskNotes` text DEFAULT NULL,
`ProcessedFolder` char(255) DEFAULT '',
`SourceHttpSql` mediumtext DEFAULT NULL,
`UniqueImport` char(1) NOT NULL DEFAULT '0',
`ExtractBinarySql` text DEFAULT NULL,
`ExtractMetaSql` text DEFAULT NULL,
`ExtractUpdateSql` text DEFAULT NULL,
`PreSql` text DEFAULT NULL,
`PostSql` text DEFAULT NULL,
`Template` char(255) DEFAULT '',
`TemplateFont` char(255) DEFAULT '',
`TemplateFontSize` char(255) DEFAULT '',
`CssUrl` text DEFAULT NULL,
`PdfReport` char(255) DEFAULT '',
`IndexPage` char(255) DEFAULT '',
`IndexDescription` char(255) DEFAULT '',
`MinFileSize` int(11) DEFAULT NULL,
`MaxFileSize` int(11) DEFAULT NULL,
`IsBigFile` char(1) NOT NULL DEFAULT 'N',
`SimpleUpload` char(1) NOT NULL DEFAULT 'N',
`Disposition` char(255) DEFAULT 'inline',
`ZipOnEmail` char(1) NOT NULL DEFAULT 'N',
`ZipOnDownload` char(1) NOT NULL DEFAULT 'N',
`ZipComponents` text DEFAULT NULL,
`doocr` char(1) NOT NULL DEFAULT 'N',
`OcrDelete` char(1) NOT NULL DEFAULT 'N',
`HistoryWindow` int(11) DEFAULT 0,
`TTL` int(11) DEFAULT NULL,
`ArchiveTTL` int(11) DEFAULT NULL,
`PurgeTTL` int(11) DEFAULT NULL,
`Workflowname` char(255) DEFAULT '',
`DoEnhance` char(1) NOT NULL DEFAULT 'N',
`IsDeleted` char(1) NOT NULL DEFAULT 'N',
`DeletedAt` datetime DEFAULT NULL,
PRIMARY KEY (`Docname`, `Package`),
KEY `idx_group` (`Group`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE={collation};
CREATE TABLE `def_document_parameters` (
`def_documentparameterid` bigint(22) NOT NULL AUTO_INCREMENT,
`DocName` char(255) DEFAULT '',
`Package` char(255) NOT NULL DEFAULT '',
`Module` VARCHAR(255) DEFAULT NULL,
`Parameter` char(255) DEFAULT '',
`ParameterMap` char(255) DEFAULT '',
`ParameterParse` char(255) DEFAULT '',
`ParameterParseTime` char(255) DEFAULT '',
`Description` mediumtext DEFAULT NULL,
`ValueType` char(1) DEFAULT NULL,
`Required` char(50) DEFAULT NULL,
`Rank` char(1) DEFAULT '0',
`Example` char(255) DEFAULT '',
`Infrastructure` char(1) DEFAULT NULL,
PRIMARY KEY (`def_documentparameterid`),
KEY `idx_doc_package` (`DocName`, `Package`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE={collation};
SELECT *
FROM def_document
WHERE docname LIKE '{doc_name}'
AND Package IN ('{package}','{archetype}','ALL','SYSTEM')
SELECT *
FROM data_documentfile
WHERE DocName LIKE '{doc_name}'
AND ReferenceGuid LIKE '{reference_guid}'
AND Package IN ('{package}','{archetype}')
SELECT *
FROM data_documentfile
WHERE DocName LIKE '{doc_name}'
AND Context LIKE '{context}'
AND Package IN ('{package}','{archetype}')
SELECT *
FROM data_documentfile
WHERE Guid LIKE '{guid}'
AND Package IN ('{package}','{archetype}')
UPDATE data_documentfile
SET IconName = '{icon_name}',
IconWidth = {width},
IconHeight = {height},
IconSize = {size},
FileName = '{file_name}'
WHERE Guid = '{guid}'
UPDATE data_documentfile
SET PreviewName = '{preview_name}',
PreviewWidth = {width},
PreviewHeight = {height},
PreviewSize = {size}
WHERE Guid = '{guid}'
INSERT INTO def_document (Docname, Package, Project)
VALUES ('{doc_name}','{package}','{project}')
UPDATE data_documentfile
SET DoEnhance = 'N',
EnhancedAt = NOW(),
AiSummary = '{safe_summary}'
WHERE Docname = '{safe_docname}'
AND Context = '{safe_context}'
UPDATE data_documentfile
SET DoEnhance = 'Y',
EnhancedAt = NOW()
WHERE Docname = '{safe_docname}'
AND Context = '{safe_context}'
AND (DoEnhance IS NULL OR DoEnhance = '')