diff --git a/database/mssql/scripts/versions/revert/v_48_ddl_revert.sql b/database/mssql/scripts/versions/revert/v_48_ddl_revert.sql new file mode 100644 index 000000000..48ab33189 --- /dev/null +++ b/database/mssql/scripts/versions/revert/v_48_ddl_revert.sql @@ -0,0 +1,53 @@ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +SET NOCOUNT ON +GO + +SET XACT_ABORT ON +GO +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE +BEGIN TRANSACTION +GO + +/* +The following DELETE statement is intentionally commented out. +This is because, these permit types are a permanent part of the production db +and there is no expectation that they will be deleted at any point. + +If at all needed, the following query can be executed manually in prod at the team's discretion. + +IMPORTANT: Analyze the impact from foreign key constraints in child tables +before deleting the permit types. + +*/ + +-- DELETE FROM [permit].[ORBC_PERMIT_TYPE] WHERE PERMIT_TYPE IN ('QRFR', 'STFR') +-- GO + + +IF @@ERROR <> 0 SET NOEXEC ON +GO + +DECLARE @VersionDescription VARCHAR(255) +SET @VersionDescription = 'Reverting adding QRFR and STFR permit types to ORBC_PERMIT_TYPE table' + +INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [RELEASE_DATE]) VALUES (47, @VersionDescription, 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 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_48_ddl.sql b/database/mssql/scripts/versions/v_48_ddl.sql new file mode 100644 index 000000000..69b5b811e --- /dev/null +++ b/database/mssql/scripts/versions/v_48_ddl.sql @@ -0,0 +1,40 @@ +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 + +INSERT [permit].[ORBC_PERMIT_TYPE] ([PERMIT_TYPE], [NAME]) VALUES (N'QRFR', N'Non-Resident Quarterly ICBC Basic Insurance (FR)') +INSERT [permit].[ORBC_PERMIT_TYPE] ([PERMIT_TYPE], [NAME]) VALUES (N'STFR', N'Non-Resident Single Trip ICBC Basic Insurance (FR)') + +IF @@ERROR <> 0 SET NOEXEC ON +GO + +DECLARE @VersionDescription VARCHAR(255) +SET @VersionDescription = 'Add QRFR and STFR permit types to ORBC_PERMIT_TYPE table' + +INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [UPDATE_SCRIPT], [REVERT_SCRIPT], [RELEASE_DATE]) VALUES (48, @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 diff --git a/database/mssql/test/versions/v_48_1_test.sql b/database/mssql/test/versions/v_48_1_test.sql new file mode 100644 index 000000000..1a7a46339 --- /dev/null +++ b/database/mssql/test/versions/v_48_1_test.sql @@ -0,0 +1,5 @@ +-- Test that the auth groups have been inserted correctly +SET NOCOUNT ON + +SELECT COUNT(*) FROM $(DB_NAME).[permit].[ORBC_PERMIT_TYPE] +WHERE PERMIT_TYPE IN ('STFR', 'QRFR') diff --git a/database/mssql/test/versions/v_48_test.sh b/database/mssql/test/versions/v_48_test.sh new file mode 100644 index 000000000..d9a61389d --- /dev/null +++ b/database/mssql/test/versions/v_48_test.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Retrieve arguments +source ${SCRIPT_DIR}/utility/getopt.sh +USAGE="-u USER -p PASS -s SERVER -d DATABASE" +parse_options "${USAGE}" ${@} + +# All database tests for database version 48 are run from this shell script. +# TESTS_DIR variable set by the calling test-runner script. + +TEST_48_1_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_48_1_test.sql | xargs) +if [[ $TEST_48_1_RESULT -eq 2 ]]; then + echo "Test 48.1 passed: QRFR and STFR permit types exist." +else + echo "******** Test 48.1 failed: QRFR and STFR permit types do not exist." +fi diff --git a/vehicles/src/common/enum/permit-type.enum.ts b/vehicles/src/common/enum/permit-type.enum.ts index b332c90fb..4fbd1de85 100644 --- a/vehicles/src/common/enum/permit-type.enum.ts +++ b/vehicles/src/common/enum/permit-type.enum.ts @@ -22,6 +22,8 @@ export enum PermitType { SINGLE_TRIP_OVERWEIGHT_OVERSIZE = 'STWS', TERM_AXLE_OVERWEIGHT = 'TRAX', TERM_OVERWEIGHT = 'TROW', + NON_RESIDENT_QUARTERLY_ICBC_BASIC_INSURANCE_FR = 'QRFR', + NON_RESIDENT_SINGLE_TRIP_ICBC_BASIC_INSURANCE_FR = 'STFR', } export enum ExtendedPermitType {