Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORV2-2968 Adding ICBC Permit types in Database #1658

Merged
merged 11 commits into from
Nov 8, 2024
53 changes: 53 additions & 0 deletions database/mssql/scripts/versions/revert/v_48_ddl_revert.sql
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions database/mssql/scripts/versions/v_48_ddl.sql
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions database/mssql/test/versions/v_48_1_test.sql
Original file line number Diff line number Diff line change
@@ -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')
16 changes: 16 additions & 0 deletions database/mssql/test/versions/v_48_test.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions vehicles/src/common/enum/permit-type.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading