-
Notifications
You must be signed in to change notification settings - Fork 38
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
[MDS-5769] CRR - Edit Mode #2944
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8f31e7e
data migration mine_report --> mine_report_submission, display only c…
taraepp a59fdec
switch over to storing the report data in the submission in order to …
taraepp b743a2f
FE test updates/fixes, BE permissions, fix styling on alert
taraepp c981b5f
fix some null errors, make current BE tests pass, disable 'edit' acti…
taraepp 931ffc9
BE tests: add some json methods to make testing easier, make a post t…
taraepp 0daf7e6
add in mine report contacts to submissions on FE and BE
taraepp 6f25e30
form buttons
taraepp 512b782
fix some date and status issues
taraepp d10cabd
add more tests. Fix some bugs that were making things fail
taraepp 1c8b1e9
make submission get mine guid from report instead of different subfac…
taraepp 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
84 changes: 84 additions & 0 deletions
84
migrations/sql/V2024.01.31.1.00__add_mine_report_columns_to_mine_report_submissions.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,84 @@ | ||
-- add the columns from mine report that are not on mine report submission | ||
ALTER TABLE mine_report_submission | ||
ADD COLUMN IF NOT EXISTS mine_report_definition_id integer, | ||
ADD COLUMN IF NOT EXISTS mine_guid uuid, | ||
ADD COLUMN IF NOT EXISTS permit_id integer, | ||
ADD COLUMN IF NOT EXISTS due_date timestamp, | ||
ADD COLUMN IF NOT EXISTS received_date timestamp default now(), | ||
ADD COLUMN IF NOT EXISTS submission_year smallint, | ||
ADD COLUMN IF NOT EXISTS deleted_ind boolean default False NOT NULL, | ||
-- ADD COLUMN IF NOT EXISTS created_by_idir varchar, // specifically excluding this one | ||
ADD COLUMN IF NOT EXISTS permit_condition_category_code varchar(3), | ||
ADD COLUMN IF NOT EXISTS description_comment varchar, | ||
ADD COLUMN IF NOT EXISTS submitter_name varchar(255), | ||
ADD COLUMN IF NOT EXISTS submitter_email varchar(255); | ||
|
||
-- bring over data from parent mine report into mine report submission | ||
UPDATE mine_report_submission | ||
SET | ||
mine_report_definition_id = mine_report.mine_report_definition_id, | ||
mine_guid = mine_report.mine_guid, | ||
permit_id = mine_report.permit_id, | ||
due_date = mine_report.due_date, | ||
received_date = mine_report.received_date, | ||
deleted_ind = mine_report.deleted_ind, | ||
permit_condition_category_code = mine_report.permit_condition_category_code, | ||
description_comment = mine_report.description_comment, | ||
submission_year = mine_report.submission_year, | ||
submitter_name = mine_report.submitter_name, | ||
submitter_email = mine_report.submitter_email | ||
FROM mine_report | ||
WHERE mine_report_submission.mine_report_id = mine_report.mine_report_id; | ||
|
||
-- add column constraints | ||
ALTER TABLE mine_report_submission | ||
-- not null constraints | ||
ALTER COLUMN mine_guid SET NOT NULL, | ||
|
||
-- foreign key constraints | ||
ADD CONSTRAINT mine_report_submission_mine_report_definition_fkey | ||
FOREIGN KEY (mine_report_definition_id) REFERENCES mine_report_definition(mine_report_definition_id), | ||
|
||
ADD CONSTRAINT mine_report_submission_mine_fkey | ||
FOREIGN KEY (mine_guid) REFERENCES mine(mine_guid), | ||
|
||
ADD CONSTRAINT mine_report_submission_permit_fkey | ||
FOREIGN KEY (permit_id) REFERENCES permit(permit_id), | ||
|
||
ADD CONSTRAINT mine_report_submission_permit_condition_category_fkey | ||
FOREIGN KEY (permit_condition_category_code) REFERENCES permit_condition_category(condition_category_code), | ||
|
||
-- existing check on 2 columns | ||
ADD CONSTRAINT submission_condition_category_or_report_def_should_be_specified | ||
CHECK | ||
( | ||
( CASE WHEN permit_condition_category_code IS NULL THEN 0 ELSE 1 END | ||
+ CASE WHEN mine_report_definition_id IS NULL THEN 0 ELSE 1 END | ||
) = 1 | ||
); | ||
|
||
-- track contacts by submission | ||
ALTER TABLE mine_report_contact | ||
ADD COLUMN IF NOT EXISTS mine_report_submission_id integer; | ||
|
||
-- insert an entry for each contact for each submission | ||
INSERT INTO mine_report_contact (name, email, mine_report_id, deleted_ind, mine_report_submission_id) | ||
SELECT | ||
mine_report_contact.name, | ||
mine_report_contact.email, | ||
mine_report_contact.mine_report_id, | ||
mine_report_contact.deleted_ind, | ||
mine_report_submission.mine_report_submission_id | ||
FROM mine_report_submission | ||
LEFT JOIN mine_report_contact | ||
ON mine_report_submission.mine_report_id = mine_report_contact.mine_report_id | ||
WHERE mine_report_contact_id IS NOT NULL; | ||
|
||
-- delete old records | ||
DELETE FROM mine_report_contact WHERE mine_report_submission_id IS NULL; | ||
|
||
-- add constraints to new column | ||
ALTER TABLE mine_report_contact | ||
ALTER COLUMN mine_report_submission_id SET NOT NULL, | ||
ADD CONSTRAINT mine_report_contact_submission_fkey | ||
FOREIGN KEY (mine_report_submission_id) REFERENCES mine_report_submission(mine_report_submission_id); |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
It's showing as a completely new file, but I changed ReportSubmissions --> ReportFileUpload, since we are only dealing with one submission and don't really need to parse its documents (much simpler here at least)