EarthCubeGeochron / Sparrow

A software tool and schema+API spec for connecting laboratory measurements to data consumers
https://sparrow-data.org
Mozilla Public License 2.0
14 stars 4 forks source link

Deleting samples #313

Open davenquinn opened 2 years ago

davenquinn commented 2 years ago

The CLI should support deleting samples (with an optional cascade to sessions). Sessions don't need to have a sample attached, so they will have to be deleted in a separate operation.

davenquinn commented 2 years ago

This needs a cascade delete to be applied to both foreign keys in the __analysis_attribute table.

davenquinn commented 2 years ago

Once that is done, here are the appropriate queries to run (with arbitrary WHERE clause):

DELETE FROM session
USING sample
WHERE session.sample_id = sample.id
  AND lab_id in (
'22-00493','22-00663','22-00665','22-00666','22-00667','22-00668','22-00669','22-00670','22-00671','22-00672'
);

DELETE FROM sample WHERE lab_id in (
'22-00493','22-00663','22-00665','22-00666','22-00667','22-00668','22-00669','22-00670','22-00671','22-00672'
);
davenquinn commented 2 years ago

Note for documentation: selecting samples you want to delete


-- Get the samples you want to delete
SELECT * FROM sample WHERE lab_id in (
'22-00493','22-00663','22-00665','22-00666','22-00667','22-00668','22-00669','22-00670','22-00671','22-00672'
);

-- Find all associated sessions (just to see how many data piecies we are deleting)
SELECT * FROM session, sample
WHERE session.sample_id = sample.id AND lab_id in (
'22-00493','22-00663','22-00665','22-00666','22-00667','22-00668','22-00669','22-00670','22-00671','22-00672'
);```