Skip to content

Commit

Permalink
Update GL_Code on docker startup and refresh DB
Browse files Browse the repository at this point in the history
  • Loading branch information
praju-aot committed Jul 4, 2024
1 parent 1b363da commit 38a139c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions database/mssql/configure-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ migrate_db_current ${MSSQL_SA_USER} "${MSSQL_SA_PASSWORD}" "${MSSQL_HOST}" ${MSS
if [[ ${MSSQL_LOAD_SAMPLE_DATA} -eq 1 ]]; then
/usr/config/utility/refresh-sample-data.sh -u ${MSSQL_SA_USER} -p '"${MSSQL_SA_PASSWORD}"' -s ${MSSQL_HOST} -d ${MSSQL_DB}
/usr/config/utility/refresh-sample-idir-users.sh -u ${MSSQL_SA_USER} -p '"${MSSQL_SA_PASSWORD}"' -s ${MSSQL_HOST} -d ${MSSQL_DB}
/usr/config/utility/refresh-paybc-gl-code.sh -u ${MSSQL_SA_USER} -p '"${MSSQL_SA_PASSWORD}"' -s ${MSSQL_HOST} -d ${MSSQL_DB}
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SET NOCOUNT ON
GO
UPDATE [permit].[ORBC_PERMIT_TYPE] SET GL_CODE='$(GL_CODE)' WHERE PERMIT_TYPE= '$(PERMIT_TYPE)'
GO
21 changes: 21 additions & 0 deletions database/mssql/scripts/utility/refresh-paybc-gl-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Retrieve arguments
source ${SCRIPT_DIR}/utility/getopt.sh
USAGE="-u ORBC_USER -p ORBC_PASS -s ORBC_SERVER -d ORBC_DATABASE"
parse_options "${USAGE}" ${@}

# Clear out all records from the pending IDIR users table
sqlcmd -C -U ${ORBC_USER} -P "${ORBC_PASS}" -S ${ORBC_SERVER} -d ${ORBC_DATABASE} -Q "SET NOCOUNT ON; UPDATE permit.ORBC_PERMIT_TYPE SET GL_CODE=NULL"

(
# PAYBC_GL_CODE environment variable must be a string representing an array
# of tuples in the format PERMIT_TUPE,GL_CODE separated by single space characters.
# For example "TROS,000.00000.00000.0000.0000000.000000.0000 TROW,EOF000.00000.00000.0000.0000000.000000.0000"
for i in ${PAYBC_GL_CODE}
do
IFS=","; set -- $i
echo "Updating permit type ${1} with GL_CODE ${2}"
sqlcmd -C -U ${ORBC_USER} -P "${ORBC_PASS}" -S ${ORBC_SERVER} -d ${ORBC_DATABASE} -v PERMIT_TYPE=${1} GL_CODE=${2} -i ${SCRIPT_DIR}/sampledata/permit.ORBC_PERMIT_TYPE.Table.sql
done
)
1 change: 1 addition & 0 deletions database/mssql/scripts/utility/reset-moti-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ if [[ "${REPLY}" == "yes" ]] || [[ $1 == "force" ]]; then
if [[ ${MSSQL_LOAD_SAMPLE_DATA} -eq 1 ]]; then
${SCRIPT_DIR}/utility/refresh-sample-data.sh -u ${TEST_MOTI_USER:-$MSSQL_MOTI_USER} -p '"${TEST_MOTI_PASSWORD:-$MSSQL_MOTI_PASSWORD}"' -s ${TEST_MOTI_HOST:-$MSSQL_MOTI_HOST} -d ${TEST_MOTI_DB:-$MSSQL_MOTI_DB}
${SCRIPT_DIR}/utility/refresh-sample-idir-users.sh -u ${TEST_MOTI_USER:-$MSSQL_MOTI_USER} -p '"${TEST_MOTI_PASSWORD:-$MSSQL_MOTI_PASSWORD}"' -s ${TEST_MOTI_HOST:-$MSSQL_MOTI_HOST} -d ${TEST_MOTI_DB:-$MSSQL_MOTI_DB}
${SCRIPT_DIR}/utility/refresh-paybc-gl-code.sh -u ${TEST_MOTI_USER:-$MSSQL_MOTI_USER} -p '"${TEST_MOTI_PASSWORD:-$MSSQL_MOTI_PASSWORD}"' -s ${TEST_MOTI_HOST:-$MSSQL_MOTI_HOST} -d ${TEST_MOTI_DB:-$MSSQL_MOTI_DB}
fi

echo "Finished reset of ORBC database."
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
MSSQL_ENCRYPT: ${MSSQL_ENCRYPT}
MSSQL_RUN_TESTS: ${MSSQL_RUN_TESTS}
SAMPLE_PENDING_IDIR_USERS: ${SAMPLE_PENDING_IDIR_USERS}
PAYBC_GL_CODE: ${PAYBC_GL_CODE}
MSSQL_LOAD_SAMPLE_DATA: ${MSSQL_LOAD_SAMPLE_DATA}
MSSQL_MOTI_HOST: ${MSSQL_MOTI_HOST}
MSSQL_MOTI_DB: ${MSSQL_MOTI_DB}
Expand Down

0 comments on commit 38a139c

Please sign in to comment.