From cd70382196e5ca6842ea33806d504ca4b7fd9c07 Mon Sep 17 00:00:00 2001 From: praju-aot Date: Thu, 2 Jan 2025 12:45:45 -0500 Subject: [PATCH 1/2] ORV2-3095 Fix revision history in Permit templates --- dops/src/modules/common/cdogs.service.ts | 4 ++- .../helper/format-template-data.helper.ts | 32 +++++++++++++------ .../interface/permit.template.interface.ts | 2 ++ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/dops/src/modules/common/cdogs.service.ts b/dops/src/modules/common/cdogs.service.ts index 049b8050a..7feb19f4c 100644 --- a/dops/src/modules/common/cdogs.service.ts +++ b/dops/src/modules/common/cdogs.service.ts @@ -74,7 +74,9 @@ export class CdogsService { } // The above implemenation is a fail proof version to always get the latest version --end - const templateFile = filteredTemplateFiles.at(0); + const templateFile = filteredTemplateFiles.at( + filteredTemplateFiles?.length - 1, + ); const token = await getAccessToken( GovCommonServices.COMMON_DOCUMENT_GENERATION_SERVICE, diff --git a/vehicles/src/common/helper/format-template-data.helper.ts b/vehicles/src/common/helper/format-template-data.helper.ts index 8181ef3d8..b851fba92 100644 --- a/vehicles/src/common/helper/format-template-data.helper.ts +++ b/vehicles/src/common/helper/format-template-data.helper.ts @@ -38,6 +38,8 @@ export const formatTemplateData = ( revisions: [], permitData: null, loas: '', + permitIssueDateTime: '', + revisionIssueDateTime: '', }; template.permitData = JSON.parse(permit.permitData.permitData) as PermitData; @@ -95,22 +97,34 @@ export const formatTemplateData = ( permit.permitTransactions?.at(0)?.transactionAmount, ).toString(); + if (permit.revision > 0) { + template.revisionIssueDateTime = convertUtcToPt( + permit.permitIssueDateTime, + 'MMM. D, YYYY, hh:mm a Z', + ); + } + revisionHistory?.forEach((revision) => { if ( revision.permitStatus == ApplicationStatus.ISSUED || revision.permitStatus == ApplicationStatus.VOIDED || revision.permitStatus == ApplicationStatus.REVOKED || - revision.permitId === permit.permitId + revision.permitStatus == ApplicationStatus.SUPERSEDED ) { - template.revisions.push({ - timeStamp: convertUtcToPt( - revision.permitId === permit.permitId - ? permit.permitIssueDateTime - : revision.permitIssueDateTime, + if (permit.originalPermitId === revision.permitId) { + template.permitIssueDateTime = convertUtcToPt( + revision.permitIssueDateTime, 'MMM. D, YYYY, hh:mm a Z', - ), - description: revision.comment, - }); + ); + } else { + template.revisions.push({ + timeStamp: convertUtcToPt( + revision.permitIssueDateTime, + 'MMM. D, YYYY, hh:mm a Z', + ), + description: revision.comment, + }); + } } }); diff --git a/vehicles/src/common/interface/permit.template.interface.ts b/vehicles/src/common/interface/permit.template.interface.ts index 1e66955ab..971cdc9f0 100644 --- a/vehicles/src/common/interface/permit.template.interface.ts +++ b/vehicles/src/common/interface/permit.template.interface.ts @@ -14,6 +14,8 @@ export interface PermitTemplateData { revisions: Revision[]; permitData?: PermitData; loas?: string; + permitIssueDateTime?: string; + revisionIssueDateTime?: string; } interface Revision { From 9ce41731d75f6bcbe8ff276264c827e412e49953 Mon Sep 17 00:00:00 2001 From: praju-aot Date: Thu, 2 Jan 2025 13:54:57 -0500 Subject: [PATCH 2/2] ORV2-3095 DB changes for the new templates --- .../versions/revert/v_53_ddl_revert.sql | 222 ++++++++ database/mssql/scripts/versions/v_53_ddl.sql | 492 ++++++++++++++++++ 2 files changed, 714 insertions(+) create mode 100644 database/mssql/scripts/versions/revert/v_53_ddl_revert.sql create mode 100644 database/mssql/scripts/versions/v_53_ddl.sql diff --git a/database/mssql/scripts/versions/revert/v_53_ddl_revert.sql b/database/mssql/scripts/versions/revert/v_53_ddl_revert.sql new file mode 100644 index 000000000..7ebe17993 --- /dev/null +++ b/database/mssql/scripts/versions/revert/v_53_ddl_revert.sql @@ -0,0 +1,222 @@ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +SET NOCOUNT ON +GO + +SET XACT_ABORT ON +GO + +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE +GO + +BEGIN TRANSACTION +GO + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT_TEMPLATE] +WHERE DOCUMENT_ID IN ( + SELECT ID + FROM [dops].[ORBC_DOCUMENT] + WHERE FILE_NAME = 'permit-template-v2.docx' + ) + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT] +WHERE FILE_NAME = 'permit-template-v2.docx' + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT_TEMPLATE] +WHERE DOCUMENT_ID IN ( + SELECT ID + FROM [dops].[ORBC_DOCUMENT] + WHERE FILE_NAME = 'permit-void-template-v2.docx' + ) + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT] +WHERE FILE_NAME = 'permit-void-template-v2.docx' + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT_TEMPLATE] +WHERE DOCUMENT_ID IN ( + SELECT ID + FROM [dops].[ORBC_DOCUMENT] + WHERE FILE_NAME = 'permit-revoked-template-v2.docx' + ) + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT] +WHERE FILE_NAME = 'permit-revoked-template-v2.docx' + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT_TEMPLATE] +WHERE DOCUMENT_ID IN ( + SELECT ID + FROM [dops].[ORBC_DOCUMENT] + WHERE FILE_NAME = 'stos-template-v2.docx' + ) + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT] +WHERE FILE_NAME = 'stos-template-v2.docx' + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT_TEMPLATE] +WHERE DOCUMENT_ID IN ( + SELECT ID + FROM [dops].[ORBC_DOCUMENT] + WHERE FILE_NAME = 'stos-void-template-v2.docx' + ) + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT] +WHERE FILE_NAME = 'stos-void-template-v2.docx' + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT_TEMPLATE] +WHERE DOCUMENT_ID IN ( + SELECT ID + FROM [dops].[ORBC_DOCUMENT] + WHERE FILE_NAME = 'stos-revoked-template-v2.docx' + ) + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT] +WHERE FILE_NAME = 'stos-revoked-template-v2.docx' + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT_TEMPLATE] +WHERE DOCUMENT_ID IN ( + SELECT ID + FROM [dops].[ORBC_DOCUMENT] + WHERE FILE_NAME = 'mfp-template-v2.docx' + ) + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT] +WHERE FILE_NAME = 'mfp-template-v2.docx' + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT_TEMPLATE] +WHERE DOCUMENT_ID IN ( + SELECT ID + FROM [dops].[ORBC_DOCUMENT] + WHERE FILE_NAME = 'mfp-void-template-v2.docx' + ) + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT] +WHERE FILE_NAME = 'mfp-void-template-v2.docx' + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT_TEMPLATE] +WHERE DOCUMENT_ID IN ( + SELECT ID + FROM [dops].[ORBC_DOCUMENT] + WHERE FILE_NAME = 'mfp-revoked-template-v2.docx' + ) + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DELETE [dops].[ORBC_DOCUMENT] +WHERE FILE_NAME = 'mfp-revoked-template-v2.docx' + +DECLARE @VersionDescription VARCHAR(255) + +SET @VersionDescription = 'Revert permit templates from v2 to v1' + +INSERT [dbo].[ORBC_SYS_VERSION] ( + [VERSION_ID] + ,[DESCRIPTION] + ,[RELEASE_DATE] + ) +VALUES ( + 52 + ,@VersionDescription + ,getutcdate() + ) +GO + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +COMMIT TRANSACTION +GO + +IF @@ERROR <> 0 + SET NOEXEC ON +GO + +DECLARE @Success AS BIT + +SET @Success = 1 +SET NOEXEC OFF + +IF (@Success = 1) + PRINT 'The database revert succeeded' +ELSE +BEGIN + IF @@TRANCOUNT > 0 + ROLLBACK TRANSACTION + + PRINT 'The database revert failed' +END +GO \ No newline at end of file diff --git a/database/mssql/scripts/versions/v_53_ddl.sql b/database/mssql/scripts/versions/v_53_ddl.sql new file mode 100644 index 000000000..960deadbe --- /dev/null +++ b/database/mssql/scripts/versions/v_53_ddl.sql @@ -0,0 +1,492 @@ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +SET NOCOUNT ON +GO + +SET XACT_ABORT ON +GO +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE +GO +BEGIN TRANSACTION +GO + + +IF @@ERROR <> 0 SET NOEXEC ON +GO +DECLARE @NewGuid UNIQUEIDENTIFIER +SET @NewGuid =NEWID(); +INSERT [dops].[ORBC_DOCUMENT] ( + [S3_OBJECT_ID], + [S3_VERSION_ID], + [S3_LOCATION], + [OBJECT_MIME_TYPE], + [FILE_NAME], + [DMS_VERSION_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + @NewGuid, + NULL, + N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev@moti-int.objectstore.gov.bc.ca/' + CONVERT(NVARCHAR(36), @NewGuid), + N'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + N'permit-template-v2.docx', + 1, + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + + +INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ( + [TEMPLATE_NAME], + [TEMPLATE_VERSION], + [DOCUMENT_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + N'PERMIT', + 2, + (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME = 'permit-template-v2.docx'), + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +SET @NewGuid = NEWID(); + + +INSERT [dops].[ORBC_DOCUMENT] ( + [S3_OBJECT_ID], + [S3_VERSION_ID], + [S3_LOCATION], + [OBJECT_MIME_TYPE], + [FILE_NAME], + [DMS_VERSION_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + @NewGuid, + NULL, + N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev@moti-int.objectstore.gov.bc.ca/' + CONVERT(NVARCHAR(36), @NewGuid), + N'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + N'permit-template-void-template-v2.docx', + 1, + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ( + [TEMPLATE_NAME], + [TEMPLATE_VERSION], + [DOCUMENT_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + N'PERMIT_VOID', + 2, + (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME = 'permit-template-void-template-v2.docx'), + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +SET @NewGuid = NEWID(); + +INSERT [dops].[ORBC_DOCUMENT] ( + [S3_OBJECT_ID], + [S3_VERSION_ID], + [S3_LOCATION], + [OBJECT_MIME_TYPE], + [FILE_NAME], + [DMS_VERSION_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + @NewGuid, + NULL, + N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev@moti-int.objectstore.gov.bc.ca/' + CONVERT(NVARCHAR(36), @NewGuid), + N'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + N'permit-template-revoked-template-v2.docx', + 1, + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ( + [TEMPLATE_NAME], + [TEMPLATE_VERSION], + [DOCUMENT_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + N'PERMIT_REVOKED', + 2, + (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME = 'permit-template-revoked-template-v2.docx'), + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +SET @NewGuid = NEWID(); + +INSERT [dops].[ORBC_DOCUMENT] ( + [S3_OBJECT_ID], + [S3_VERSION_ID], + [S3_LOCATION], + [OBJECT_MIME_TYPE], + [FILE_NAME], + [DMS_VERSION_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + @NewGuid, + NULL, + N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev@moti-int.objectstore.gov.bc.ca/' + CONVERT(NVARCHAR(36), @NewGuid), + N'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + N'stos-template-v2.docx', + 1, + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ( + [TEMPLATE_NAME], + [TEMPLATE_VERSION], + [DOCUMENT_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + N'PERMIT_STOS', + 2, + (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME = 'stos-template-v2.docx'), + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +SET @NewGuid = NEWID(); + +INSERT [dops].[ORBC_DOCUMENT] ( + [S3_OBJECT_ID], + [S3_VERSION_ID], + [S3_LOCATION], + [OBJECT_MIME_TYPE], + [FILE_NAME], + [DMS_VERSION_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + @NewGuid, + NULL, + N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev@moti-int.objectstore.gov.bc.ca/' + CONVERT(NVARCHAR(36), @NewGuid), + N'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + N'stos-void-template-v2.docx', + 1, + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ( + [TEMPLATE_NAME], + [TEMPLATE_VERSION], + [DOCUMENT_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + N'PERMIT_STOS_VOID', + 2, + (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME = 'stos-void-template-v2.docx'), + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +SET @NewGuid = NEWID(); + +INSERT [dops].[ORBC_DOCUMENT] ( + [S3_OBJECT_ID], + [S3_VERSION_ID], + [S3_LOCATION], + [OBJECT_MIME_TYPE], + [FILE_NAME], + [DMS_VERSION_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + @NewGuid, + NULL, + N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev@moti-int.objectstore.gov.bc.ca/' + CONVERT(NVARCHAR(36), @NewGuid), + N'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + N'stos-revoked-template-v2.docx', + 1, + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + + +INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ( + [TEMPLATE_NAME], + [TEMPLATE_VERSION], + [DOCUMENT_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + N'PERMIT_STOS_REVOKED', + 2, + (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME = 'stos-revoked-template-v2.docx'), + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +SET @NewGuid = NEWID(); + +INSERT [dops].[ORBC_DOCUMENT] ( + [S3_OBJECT_ID], + [S3_VERSION_ID], + [S3_LOCATION], + [OBJECT_MIME_TYPE], + [FILE_NAME], + [DMS_VERSION_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + @NewGuid, + NULL, + N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev@moti-int.objectstore.gov.bc.ca/' + CONVERT(NVARCHAR(36), @NewGuid), + N'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + N'mfp-template-v2.docx', + 1, + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ( + [TEMPLATE_NAME], + [TEMPLATE_VERSION], + [DOCUMENT_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + N'PERMIT_MFP', + 2, + (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME = 'mfp-template-v2.docx'), + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +SET @NewGuid = NEWID(); + +INSERT [dops].[ORBC_DOCUMENT] ( + [S3_OBJECT_ID], + [S3_VERSION_ID], + [S3_LOCATION], + [OBJECT_MIME_TYPE], + [FILE_NAME], + [DMS_VERSION_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + @NewGuid, + NULL, + N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev@moti-int.objectstore.gov.bc.ca/' + CONVERT(NVARCHAR(36), @NewGuid), + N'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + N'mfp-void-template-v2.docx', + 1, + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ( + [TEMPLATE_NAME], + [TEMPLATE_VERSION], + [DOCUMENT_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + N'PERMIT_MFP_VOID', + 2, + (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME = 'mfp-void-template-v2.docx'), + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +SET @NewGuid = NEWID(); + +INSERT [dops].[ORBC_DOCUMENT] ( + [S3_OBJECT_ID], + [S3_VERSION_ID], + [S3_LOCATION], + [OBJECT_MIME_TYPE], + [FILE_NAME], + [DMS_VERSION_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + @NewGuid, + NULL, + N'https://moti-int.objectstore.gov.bc.ca/tran_api_orbc_docs_dev/tran_api_orbc_docs_dev@moti-int.objectstore.gov.bc.ca/' + CONVERT(NVARCHAR(36), @NewGuid), + N'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + N'mfp-revoked-template-v2.docx', + 1, + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) + +INSERT [dops].[ORBC_DOCUMENT_TEMPLATE] ( + [TEMPLATE_NAME], + [TEMPLATE_VERSION], + [DOCUMENT_ID], + [CONCURRENCY_CONTROL_NUMBER], + [DB_CREATE_USERID], + [DB_CREATE_TIMESTAMP], + [DB_LAST_UPDATE_USERID], + [DB_LAST_UPDATE_TIMESTAMP] +) +VALUES ( + N'PERMIT_MFP_REVOKED', + 2, + (SELECT ID FROM [dops].[ORBC_DOCUMENT] WHERE FILE_NAME = 'mfp-revoked-template-v2.docx'), + 1, + N'dops', + GETUTCDATE(), + N'dops', + GETUTCDATE() +) +IF @@ERROR <> 0 SET NOEXEC ON +GO + +DECLARE @VersionDescription VARCHAR(255) +SET @VersionDescription = 'Update all permit templates to v2 to fix rev history' + +INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [UPDATE_SCRIPT], [REVERT_SCRIPT], [RELEASE_DATE]) VALUES (53, @VersionDescription, '$(UPDATE_SCRIPT)', '$(REVERT_SCRIPT)', getutcdate()) +IF @@ERROR <> 0 SET NOEXEC ON +GO + +COMMIT TRANSACTION +GO +IF @@ERROR <> 0 SET NOEXEC ON +GO +DECLARE @Success AS BIT +SET @Success = 1 +SET NOEXEC OFF +IF (@Success = 1) PRINT 'The database update succeeded' +ELSE BEGIN + IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION + PRINT 'The database update failed' +END +GO