-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix licence issues failing to insert for review (#867)
https://eaflood.atlassian.net/browse/WATER-4375 In recent testing of triggering an SROC two-part tariff bill run, we've seen errors thrown by the `PersistAllocatedLicenceToResultsService`. After investigating it is not the issue. It was being asked to persist every issue for every element and return found by `DetermineLicenceIssuesService` in its `issues` field. No de-duping of the issues is taking place so it's blowing past the 255-char limit for the DB field for some licences. This causes the bill run to fail and the system app to crash (but we'll deal with that in another fix!) This change will de-dupe the issues found _before_ they are persisted to keep the entry to a minimum. But should a licence have every single issue the resulting value would still be more than 255 characters. So, we also add a migration to alter the `issues` column in `review_licences`, `review_charge_elements` and `review_returns` from `varchar(255)` to `text` which has no limit (in practical terms).
- Loading branch information
1 parent
a1b533a
commit b2e3966
Showing
3 changed files
with
90 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
db/migrations/public/20240327200101_alter-review-issues-columns.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict' | ||
|
||
exports.up = async function (knex) { | ||
await knex | ||
.schema | ||
.alterTable('review_charge_elements', (table) => { | ||
table.text('issues').alter() | ||
}) | ||
|
||
await knex | ||
.schema | ||
.alterTable('review_licences', (table) => { | ||
table.text('issues').alter() | ||
}) | ||
|
||
return knex | ||
.schema | ||
.alterTable('review_returns', (table) => { | ||
table.text('issues').alter() | ||
}) | ||
} | ||
|
||
exports.down = async function (knex) { | ||
await knex | ||
.schema | ||
.alterTable('review_charge_elements', (table) => { | ||
table.string('issues').alter() | ||
}) | ||
|
||
await knex | ||
.schema | ||
.alterTable('review_licences', (table) => { | ||
table.string('issues').alter() | ||
}) | ||
|
||
return knex | ||
.schema | ||
.alterTable('review_returns', (table) => { | ||
table.string('issues').alter() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters