-
Notifications
You must be signed in to change notification settings - Fork 0
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
Restructure models by type and scheme #78
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cruikshanks
added
the
housekeeping
Refactoring, tidying up or other work which supports the project
label
Jan 5, 2023
DEFRA/water-abstraction-team#69 Our next step in refactoring the models to deal with legacy issues is to identify them by type and scheme. Admittedly, we know we are just dealing with the one type (legacy) and scheme (water). But more will be coming and this helps set the groundwork for implementing base classes that allow us to start hiding some of the issues with the existing DB. So, we move the existing models into a new `models/water` folder and we add a new `LegacyModel` which all our existing classes will inherit from.
With all the movement we need to update all our references.
This means adding 2 new base models, one extending from the other with `BaseModel` as the root parent. This also means we can move out of BaseModel functionality we only added to support working with the legacy service and it's various schemas. When we get to add our own models, they won't need to inherit this cruft. Whilst doing this we were able to make some changes to the whole declaring the schema name solution. The original was made in 2016, so for example `RelatedQueryBuilder` is defunct (should have spotted that before 🤦). And as we only need this in the `LegacyBaseModel` we no longer assign our custom QueryBuilder to Objection's root Model `QueryBuilder` property. Finally, we added some documentation around all this so if we ever have to look at it again we'll have a clue what what it's all about.
Cruikshanks
force-pushed
the
restructure-models
branch
from
January 5, 2023 19:11
6d96392
to
96226bd
Compare
StuAA78
approved these changes
Jan 6, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
DEFRA/water-abstraction-team#69
Our next step in refactoring the models to deal with legacy issues is to identify them by type and scheme. Admittedly, we know we are just dealing with one type (legacy) and scheme (water). But more will be coming and this helps set the groundwork for implementing base classes that allow us to start hiding some of the issues with the existing DB.
So, we move the existing models into a new
models/water
folder and we add newLegacyBaseModel
andWaterBaseModel
which all our existing classes will inherit from. We then move any existing logic for dealing with the legacy data into theLegacyBaseModel
and take the opportunity to update it (originally based on a 2016 solution).