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

Fix unique constraint issue in licences-update job #909

Merged
merged 4 commits into from
Apr 14, 2024

Conversation

Cruikshanks
Copy link
Member

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 its licence_version_id field.

CREATE UNIQUE INDEX unique_licence_version_id_date_deleted_null ON water.charge_version_workflows USING btree (licence_version_id) WHERE (date_deleted IS NULL);

This means a licence version won't have a to_setup workflow record but will have a review 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.

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 its `licence_version_id` field.

```sql
CREATE UNIQUE INDEX unique_licence_version_id_date_deleted_null ON water.charge_version_workflows USING btree (licence_version_id) WHERE (date_deleted IS NULL);
```

This means a licence version won't have a `to_setup` workflow record but will have a `review` workflow record. Currently, we treat that as a 'result' so try to insert a new workflow record for the update 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.
@Cruikshanks Cruikshanks added the bug Something isn't working label Apr 14, 2024
@Cruikshanks Cruikshanks self-assigned this Apr 14, 2024
@Cruikshanks Cruikshanks marked this pull request as ready for review April 14, 2024 23:33
@Cruikshanks Cruikshanks merged commit 46df651 into main Apr 14, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the fix-unique-constraint-licence-updates-job branch April 14, 2024 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant