-- ============================================================================= -- MMAILTEMPLATE — TEMPLATEATTACHMENTID column (SQL Server variant) -- Migration: 20260719 — MailTemplate TemplateAttachmentId -- -- Purpose: let a MMAILTEMPLATE row serve as a friendly named index into the modern -- TATTACHMENT/ECM attachment store (base64 blob via IFileUploadBLL), alongside its existing -- ATTACHMENTFILEID/BODYFILEID columns which point at the older MFILE (path-on-disk) store used -- for SMTP sends. Correspondence's document-merge engine (CorrespondenceBLL.LoadTemplateBytesAsync -- -> GB5Shared/DocumentMerge/WordMergeEngine) already reads templates via -- IFileUploadBLL.DownloadAttachmentAsBase64(TemplateId) -- i.e. TemplateId is a raw -- TATTACHMENT.ATTACHMENTID. This column lets the Correspondence compose UI pick a template by -- friendly name (via GetSelectListMailTemplate) and resolve it to that same attachment id, -- without touching Correspondence's already-tested code at all. -- -- Purely additive: ATTACHMENTFILEID/BODYFILEID/EVENTTYPEID and EmailActionHandler's use of them -- are completely untouched. -- ============================================================================= IF NOT EXISTS ( SELECT 1 FROM sys.columns WHERE object_id = OBJECT_ID('[DBO].[MMAILTEMPLATE]') AND name = 'TEMPLATEATTACHMENTID') ALTER TABLE [DBO].[MMAILTEMPLATE] ADD TEMPLATEATTACHMENTID INT NULL DEFAULT -1; GO -- ============================================================================= -- END OF MIGRATION 20260719_MailTemplate_TemplateAttachmentId (SQL Server variant) -- =============================================================================