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
20 changes: 20 additions & 0 deletions database/mssql/scripts/versions/revert/v_47_ddl_revert.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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

DELETE FROM [permit].[ORBC_PERMIT_TYPE] WHERE PERMIT_TYPE IN ('QRFR', 'STFR')
praju-aot marked this conversation as resolved.
Show resolved Hide resolved
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 (46, @VersionDescription, getutcdate())
43 changes: 43 additions & 0 deletions database/mssql/scripts/versions/v_47_ddl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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

INSERT [permit].[ORBC_PERMIT_TYPE] ([PERMIT_TYPE], [NAME], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES (N'QRFR', N'Non-Resident Quarterly ICBC Basic Insurance (FR)', NULL, N'dbo', CAST(N'2024-11-06T21:30:33.6366667' AS DateTime2), N'dbo', CAST(N'2024-11-06TT21:30:33.6366667' AS DateTime2))
INSERT [permit].[ORBC_PERMIT_TYPE] ([PERMIT_TYPE], [NAME], [CONCURRENCY_CONTROL_NUMBER], [DB_CREATE_USERID], [DB_CREATE_TIMESTAMP], [DB_LAST_UPDATE_USERID], [DB_LAST_UPDATE_TIMESTAMP]) VALUES (N'STFR', N'Non-Resident Single Trip ICBC Basic Insurance (FR)', NULL, N'dbo', CAST(N'2024-11-06T21:30:33.6366667' AS DateTime2), N'dbo', CAST(N'2024-11-06TT21:30:33.6366667' AS DateTime2))
krishnan-aot marked this conversation as resolved.
Show resolved Hide resolved

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 (46, @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_47_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_47_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 47 are run from this shell script.
# TESTS_DIR variable set by the calling test-runner script.

TEST_47_1_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_47_1_test.sql | xargs)
if [[ $TEST_47_1_RESULT -eq 2 ]]; then
echo "Test 47.1 passed: QRFR and STFR permit types exist."
else
echo "******** Test 47.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