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

Build models for returns based on new Views #533

Merged
merged 18 commits into from
Nov 23, 2023
Merged

Conversation

Jozzey
Copy link
Contributor

@Jozzey Jozzey commented Nov 20, 2023

DEFRA/water-abstraction-team#106

As part of the work we have been doing to get migrations working in water-abstraction-system we are going to be creating all our new tables in a single schema public.

We have also decided that when there is a legacy table that we are still going to need for SROC. We are going to create a View of that table in the public schema and correct any issues with naming conventions, unused fields etc in the view. The first of these views that represent the old returns tables have been created in #531

This PR will create the models, helpers and unit tests required to be able to start to use these new views.

DEFRA/water-abstraction-team#106

As part of the work we have been doing to get migrations working in [water-abstraction-system](https://github.com/DEFRA/water-abstraction-system) we are going to be creating all our new tables in a single schema `public`.

We have also decided that when there is a legacy table that we are still going to need for SROC. We are going to create a View of that table in the `public` schema and correct any issues with naming conventions, unused fields etc in the view. The first of these views that represent the old `returns` tables have been created in #531

This PR will create the models, helpers and unit tests required to be able to start to use these new views.
@Jozzey Jozzey added the housekeeping Refactoring, tidying up or other work which supports the project label Nov 20, 2023
@Jozzey Jozzey self-assigned this Nov 20, 2023
Jozzey and others added 13 commits November 21, 2023 10:59
When building our views we are only pulling across data that is actually used. There is data in the `returns` and `lines` tables that is not used but is Not Nullable. We are therefore setting a default value for these fields rather than add useless data to our views which we then have to keep populating.
@Jozzey Jozzey marked this pull request as ready for review November 22, 2023 21:23
Copy link
Member

@Cruikshanks Cruikshanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One typo, but then a suggested change you wouldn't have to do if 'yours-truly' had done the job properly in the first place!

test/models/return-log.model.test.js Outdated Show resolved Hide resolved
test/support/helpers/return-log.helper.js Outdated Show resolved Hide resolved
@Jozzey Jozzey requested a review from Cruikshanks November 23, 2023 10:11
@Jozzey Jozzey merged commit 5d01578 into main Nov 23, 2023
6 checks passed
@Jozzey Jozzey deleted the build-view-based-models branch November 23, 2023 10:30
Jozzey added a commit that referenced this pull request Dec 6, 2023
https://eaflood.atlassian.net/browse/WATER-4057

As part of the work we have been doing on two-part tariff, we will be creating all our new tables in the default `public` schema.

We have also decided that when there is a legacy table that we are still going to need we will create a [View](https://www.postgresql.org/docs/current/sql-createview.html) of it in the `public` schema. This allows us to correct any issues with naming conventions, strip out unused fields, and join entities currently sat in different schemas. The first example of this approach was done in PR #531  in which views were created for the RETURNS schema.

We then created the new models and helpers that use them in [Build models for returns based on new Views](#533).

This is the final step in the process, we are refactoring any use of the legacy models to use the new ones and deleting all the legacy-based code.
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.

2 participants