-
Notifications
You must be signed in to change notification settings - Fork 3
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
Create a generic point component type #1436
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3f1c784
Update generic project extent name; add generic extent point
mddilley 06f62ac
Start on component work types
mddilley fc732cd
Add same work types as generic line extent; restore naming in down mi…
mddilley fc8ea5d
Prevent point generic extent from inserting more than once
mddilley db048a1
Restore point generic component if it was soft-deleted
mddilley 6510cf0
Delete generic component point type in down migration and clean up wo…
mddilley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
moped-database/migrations/1727471090930_update_generic_proj_ext/down.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
UPDATE moped_components SET is_deleted = true WHERE component_name = 'Project Extent - Generic' AND line_representation = false; | ||
|
||
UPDATE moped_components | ||
SET component_name = 'Project Extent - Generic' | ||
WHERE component_name = 'Project Extent - Generic (linear)' AND line_representation = true; |
42 changes: 42 additions & 0 deletions
42
moped-database/migrations/1727471090930_update_generic_proj_ext/up.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
UPDATE moped_components | ||
SET component_name = 'Project Extent - Generic (linear)' | ||
WHERE component_name = 'Project Extent - Generic' AND line_representation = true; | ||
|
||
-- Insert new point component for generic project extent | ||
INSERT INTO moped_components (component_name, line_representation, feature_layer_id) | ||
SELECT | ||
'Project Extent - Generic', | ||
false, | ||
5 | ||
WHERE NOT EXISTS ( | ||
SELECT * | ||
FROM | ||
moped_components | ||
WHERE (component_name, line_representation, feature_layer_id) = ('Project Extent - Generic', false, 5) | ||
); | ||
|
||
-- Restore point type component if it was previously soft-deleted | ||
UPDATE moped_components | ||
SET is_deleted = false | ||
WHERE component_name = 'Project Extent - Generic' AND line_representation = false; | ||
|
||
-- Insert same work types for generic project extent point as exist for generic project extent line | ||
WITH inserts_todo AS ( | ||
SELECT | ||
mcwt.work_type_id AS work_type_id, | ||
mc.component_id AS component_id | ||
FROM | ||
moped_component_work_types AS mcwt, | ||
moped_components AS mc | ||
WHERE | ||
mcwt.component_id = 0 | ||
AND mc.component_name = 'Project Extent - Generic' | ||
) | ||
|
||
INSERT INTO moped_component_work_types (work_type_id, component_id) | ||
SELECT | ||
work_type_id, | ||
component_id | ||
FROM | ||
inserts_todo | ||
ON CONFLICT DO NOTHING; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the spirit of having the down migrations restore the DB to the previous state, i think the right move here would be to actually hard delete the component that the up migration created. obviously, that's going to fail if there are any
moped_proj_components
that reference the component, so here are a few ideas:moped_proj_components
that reference itmoped_proj_components
to some other component type (like intersection improvement generic)moped_proj_components
which use this component type, yolo stylein any case, i don't think this is a big deal so i'm going to approve your PR! 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool - thanks for saying this, and i agree that the hard delete is the better call to get back to pre-up migration state. I'm going to make that change since the soft-delete/un-soft-delete felt weird in the first place! probably the reason my spidey sense was going off 🕷️