Remove return versions view mod log change #1263
Merged
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-4565
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!