From 6e4858eb79afa3aab2db41c5d3c0fdbada609daf Mon Sep 17 00:00:00 2001 From: Michael Franklin <22381693+illusional@users.noreply.github.com> Date: Wed, 3 Jan 2024 09:34:02 +1100 Subject: [PATCH] Fix delete project endpoint (#590) Co-authored-by: Michael Franklin --- db/python/connect.py | 2 +- db/python/tables/project.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/db/python/connect.py b/db/python/connect.py index e27e74293..c72b69fcf 100644 --- a/db/python/connect.py +++ b/db/python/connect.py @@ -28,9 +28,9 @@ 'assay', 'sequencing_group_assay', 'analysis_sequencing_group', + 'analysis_sample', 'assay_external_id', 'sequencing_group_external_id', - 'analysis_sequencing_group', 'family', 'family_participant', 'participant_phenotypes', diff --git a/db/python/tables/project.py b/db/python/tables/project.py index 2bcd60c9f..5ff51010f 100644 --- a/db/python/tables/project.py +++ b/db/python/tables/project.py @@ -389,6 +389,16 @@ async def delete_project_data( INNER JOIN sample ON sample.id = sg.sample_id WHERE sample.project = :project ); +DELETE FROM analysis_sample WHERE sample_id in ( + SELECT s.id FROM sample s + WHERE s.project = :project +); +DELETE FROM analysis_sequencing_group WHERE analysis_id in ( + SELECT id FROM analysis WHERE project = :project +); +DELETE FROM analysis_sample WHERE analysis_id in ( + SELECT id FROM analysis WHERE project = :project +); DELETE FROM assay WHERE sample_id in (SELECT id FROM sample WHERE project = :project); DELETE FROM sequencing_group WHERE sample_id IN ( SELECT id FROM sample WHERE project = :project