Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
[BI-2903] Support for program_id in germplasm table#23
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
base:epic/BI-2862
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
2bd1d472bad4ffbd8e00aad1c04a7248c4def2badeFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| ALTER TABLE germplasm | ||
| ADD COLUMN program_id UUID; | ||
| ALTER TABLE germplasm | ||
| ADD CONSTRAINT germplasm_program_fk | ||
| FOREIGN KEY (program_id) | ||
| REFERENCES public.program(id) | ||
| ON DELETE CASCADE; | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wonder if we should not cascade, seems the convention for other entities related to program like trials and studies, etc. is no action. | ||
| CREATE INDEX germplasm_program_idx ON germplasm (program_id, id); | ||
| UPDATE germplasm set program_id = pquery.program_id | ||
| FROM ( | ||
| SELECT g.id AS germplasm_id, p.id AS program_id | ||
| from germplasm g | ||
| JOIN germplasm_external_references gex ON g.id = gex.germplasm_entity_id | ||
| JOIN external_reference ex ON ex.id = gex.external_references_id | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should also constrain on the germplasm exref source being | ||
| JOIN external_reference ex2 ON ex2.external_reference_id = ex.external_reference_id | ||
| JOIN program_external_references pex ON pex.external_references_id = ex2.id | ||
| JOIN program p ON p.id = pex.program_entity_id | ||
| ) pquery | ||
| where id = pquery.germplasm_id; | ||
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.
Not applicable for deltabreed use case but may want to fix for general usage. Since foundProgramsByDbId is shared across germplasm in the batch if some germplasm have a program id and some don't then this could result in a
NullPointerExceptionon theUUID.fromStringcall becauserequest.getProgramDbId()could be null.Something like this should resolve it:
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.
Oop, yea, that's just a big old brain fart. I implemented that for other entities exactly as you described, just did this one wrong.