Fix unique constraint issue in licences-update job #909
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://eaflood.atlassian.net/browse/WATER-4437
We encountered an issue when we first ran this job with real data. We should have spotted that the
water.charge_version_workflows
table has a unique constraint on itslicence_version_id
field.This means a licence version won't have a
to_setup
workflow record but will have areview
workflow record. Currently, we treat that as a 'result' so try to insert a new workflow record for the updated licence.This is causing an error. We're not familiar with charge version workflows enough to know whether removing the constraint would cause issues.
So, we just have to accept that an updated licence might appear to be in workflow, be dealt with, but then get put straight back in because now the blocking workflow record is gone so our job adds another back in for the licence.