From f70ef45625a82e393a3e2b5c1ecd210ddad4b2f7 Mon Sep 17 00:00:00 2001 From: Shashank Shekhar Date: Wed, 5 Feb 2025 12:32:25 -0800 Subject: [PATCH] Code Update: Review Comments --- .../src/services/application/application.service.ts | 4 ++-- .../Add-application-versioning-columns.sql | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sources/packages/backend/apps/api/src/services/application/application.service.ts b/sources/packages/backend/apps/api/src/services/application/application.service.ts index ef25816edc..ce4e5066f7 100644 --- a/sources/packages/backend/apps/api/src/services/application/application.service.ts +++ b/sources/packages/backend/apps/api/src/services/application/application.service.ts @@ -461,8 +461,8 @@ export class ApplicationService extends RecordDataModelService { await this.repo.update( { id: savedDraftApplication.id }, { - precedingApplication: { id: savedDraftApplication.id } as Application, - parentApplication: { id: savedDraftApplication.id } as Application, + precedingApplication: { id: savedDraftApplication.id }, + parentApplication: { id: savedDraftApplication.id }, }, ); } diff --git a/sources/packages/backend/apps/db-migrations/src/sql/Applications/Add-application-versioning-columns.sql b/sources/packages/backend/apps/db-migrations/src/sql/Applications/Add-application-versioning-columns.sql index dbc0527fac..fa24576b5c 100644 --- a/sources/packages/backend/apps/db-migrations/src/sql/Applications/Add-application-versioning-columns.sql +++ b/sources/packages/backend/apps/db-migrations/src/sql/Applications/Add-application-versioning-columns.sql @@ -45,6 +45,7 @@ SET WHERE application_number IS NOT NULL; +-- Update parent-application-id and preceding-application-id for draft applications to the application id. UPDATE sims.applications SET @@ -53,20 +54,20 @@ SET WHERE application_number IS NULL; --- Add constraints to ensure parent-application-id and preceding-application-id are not null for non-draft and non-cancelled applications. +-- Add constraints to ensure parent-application-id and preceding-application-id are not null for non-draft applications. ALTER TABLE sims.applications ADD CONSTRAINT parent_application_id_constraint CHECK( parent_application_id IS NOT NULL - OR application_status IN ('Draft') + OR application_status = 'Draft' ), ADD CONSTRAINT preceding_application_id_constraint CHECK( preceding_application_id IS NOT NULL - OR application_status IN ('Draft') + OR application_status = 'Draft' ); -COMMENT ON CONSTRAINT parent_application_id_constraint ON sims.applications IS 'The parent application must be non-null for non-draft applications.'; +COMMENT ON CONSTRAINT parent_application_id_constraint ON sims.applications IS 'The parent application must be not null for non-draft applications.'; -COMMENT ON CONSTRAINT preceding_application_id_constraint ON sims.applications IS 'The preceding application must be non-null for non-draft applications.'; \ No newline at end of file +COMMENT ON CONSTRAINT preceding_application_id_constraint ON sims.applications IS 'The preceding application must be not null for non-draft applications.'; \ No newline at end of file