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

Remove return versions view mod log change #1263

Merged
merged 4 commits into from
Aug 18, 2024

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented Aug 16, 2024

https://eaflood.atlassian.net/browse/WATER-4565

Part of the work to display a licence's history to users (mod log)

In Add mod_log field to return versions view, we added a migration to add the new mod_log field to the return version view. This field was intended to hold details from the linked NALD mod log record, such as who, when, and why the version was created.

However, we've since learned that a version in NALD can have multiple mod log records. So, let's rename the field mod_logs and change its default to an array. 😜

It's a trap!

We have made the same mistake as the previous team. When we believed that a version (charge, licence, or return) had a one-to-one relationship with NALD mod log records, a JSONB field in each was a suitable solution to capturing just the information we needed. After all, it's only the historical records we have to worry about.

But when we learned that a version record could be linked to multiple mod logs, we should have taken a different approach. Instead, we ploughed on with our JSON column altering its name and default to match. 🤦😬

Once you've started down the JSONB road, it is easy to get trapped!

Thankfully, we've come to our senses before this saw the light of day in production. The mod log data we are importing needs to go into its own table, and we will link our version records accordingly. A 'standard' relationship database solution.

We've made a change to water-abstraction-service to delete the column migrations and add a new table one instead. This is because of the interaction between our views and the tables: you cannot drop a column referenced by a view.

That means we need to do the same thing here: delete the migration we added and pretend it never happened!

https://eaflood.atlassian.net/browse/WATER-4565

> Part of the work to display a licence's history to users (mod log)

In [Add mod_log field to return versions view](#1252), we added a migration to add the new `mod_log` field to the charge, licence, and return version views. This field was intended to hold details from the linked NALD mod log record, such as who, when, and why the version was created.

However, we've since learned that a version in NALD can have multiple mod log records. Therefore, we want to change the name to `mod_logs` to make that clear.

Because the previous migrations have not yet been released, we'll update them rather than add new ones.

We also overlooked telling Objection.js that the field is JSON in the models. So, we do that as part of this change as well.
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label Aug 16, 2024
@Cruikshanks Cruikshanks self-assigned this Aug 16, 2024
@Cruikshanks Cruikshanks changed the title Rename mod_log field in version views Rename mod_log field in return version view Aug 16, 2024
This just brings it inline with the other legacy migrations. We should have spotted it at the time.
@Cruikshanks Cruikshanks changed the title Rename mod_log field in return version view Remove return versions view mod log change Aug 18, 2024
@Cruikshanks Cruikshanks force-pushed the alter-mod-log-in-version-views branch from c641744 to 8792685 Compare August 18, 2024 09:11
@Cruikshanks Cruikshanks marked this pull request as ready for review August 18, 2024 10:00
@Cruikshanks Cruikshanks merged commit ca37871 into main Aug 18, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the alter-mod-log-in-version-views branch August 18, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant