diff --git a/.github/workflows/check-database-migration-files.yml b/.github/workflows/check-database-migration-files.yml new file mode 100644 index 000000000000..dcd30cff32b2 --- /dev/null +++ b/.github/workflows/check-database-migration-files.yml @@ -0,0 +1,51 @@ +name: Database Migration Files + +on: + pull_request: + branches: + - '**' + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - name: Checkout current branch + uses: actions/checkout@v3 + + - name: Fetch base branch + run: | + git fetch origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }} + + - name: Check Migration Issues + run: | + echo "Checking for migration issues..." + # Set the directory for migrations + MIGRATION_DIR=db/migration + + # Get latest timestamp from the base branch + BASE_MIGRATION_FILES=$(git ls-tree -r --name-only origin/${{ github.base_ref }} -- $MIGRATION_DIR) + LATEST_BASE_TIMESTAMP=$(echo "$BASE_MIGRATION_FILES" | awk -F'_' '{print $1}' | sort -n | tail -n 1) + + echo "Latest timestamp in base branch: $LATEST_BASE_TIMESTAMP" + + # List current migration files + CURRENT_MIGRATION_FILES=$(ls $MIGRATION_DIR) + echo "Current migration files: $CURRENT_MIGRATION_FILES" + + # Check for duplicates + DUPLICATE_FILES=$(echo "$CURRENT_MIGRATION_FILES" | awk -F'_' '{print $1}' | sort | uniq -d) + if [ ! -z "$DUPLICATE_FILES" ]; then + echo "Duplicate timestamps found: $DUPLICATE_FILES" + exit 1 + fi + + # Check for timestamps before the latest in the base branch + for FILE in $CURRENT_MIGRATION_FILES; do + TIMESTAMP=$(echo $FILE | awk -F'_' '{print $1}') + if [[ "$TIMESTAMP" < "$LATEST_BASE_TIMESTAMP" ]]; then + echo "Timestamp $TIMESTAMP in $FILE is before the latest timestamp in the base branch." + exit 1 + fi + done + + echo "All migration files are valid." diff --git a/src/main/resources/db/migration/V2024_10_10_1047__new_scenario.sql b/src/main/resources/db/migration/V2024_10_10_1047__new_scenario.sql new file mode 100644 index 000000000000..f48028e7b611 --- /dev/null +++ b/src/main/resources/db/migration/V2024_10_10_1047__new_scenario.sql @@ -0,0 +1,52 @@ +/** + * Add scenario + */ +INSERT INTO dbs.scenario (name, notifications_to_delete, notifications_to_create) +VALUES ('Scenario.AAA6.JudgmentsOnline.IssuedCCJ.Claimant', + '{"Notice.AAA6.ClaimantIntent.CCJ.Requested.Claimant", + "Notice.AAA6.ClaimantIntent.RequestedCCJ.ClaimantAcceptedDefendantPlan.Claimant", + "Notice.AAA6.ClaimantIntent.RequestCCJ.ClaimantAcceptOrRejectPlan.SettlementRequested.NoDefResponse.Claimant", + "Notice.AAA6.ClaimantIntent.RequestCCJ.ClaimantAcceptOrRejectPlan.SettlementRequested.DefPaymentMissed.Claimant"}', + '{"Notice.AAA6.JudgmentsOnline.IssuedCCJ.Claimant": ["djClaimantNotificationMessage", "djClaimantNotificationMessageCy"]}'); + +/** + * Add notification template + */ +INSERT INTO dbs.dashboard_notifications_templates ( template_name, title_En, title_Cy, description_En, description_Cy + , notification_role) +VALUES ('Notice.AAA6.JudgmentsOnline.IssuedCCJ.Claimant', + 'A judgment against the defendant has been made', + 'Mae dyfarniad wedi’i wneud yn erbyn y diffynnydd', + '
The defendant should now pay you according to the terms of the judgment.
Once they do, you should confirm that they’ve paid you the full amount that you’re owed.
If they do not pay you by the date on the judgment, you can ask for enforcement action to be taken against them.
If you need to change the terms of payment within the judgment, such as the instalments you had previously agreed, you can ${djClaimantNotificationMessage}.
Dylai’r diffynnydd eich talu yn unol â thelerau’r dyfarniad.
Unwaith y byddant yn gwneud hynny, dylech gadarnhau eu bod wedi talu’r swm llawn sy’n ddyledus i chi.
Os na fyddant yn eich talu erbyn y dyddiad ar y dyfarniad, gallwch ofyn am gymryd camau gorfodi yn eu herbyn.
Os oes arnoch angen newid y telerau talu o fewn y dyfarniad, fel y rhandaliadau roeddech wedi cytuno arnynt yn flaenorol, gallwch ${djClaimantNotificationMessageCy}.