There's a bit easier way +)
SELECT id FROM environment WHERE name="foo";
DELETE FROM status WHERE task_id IN (SELECT id FROM task WHERE environment_id="env_id") ;
DELETE FROM task WHERE environment_id="env_id";
DELETE FROM session WHERE environment_id="env_id" ;
DELETE FROM environment WHERE id = "env_id";
There's a bit easier way +)
SELECT id FROM environment WHERE name="foo";
DELETE FROM status WHERE task_id IN (SELECT id FROM task WHERE environment_ id="env_ id") ;
DELETE FROM task WHERE environment_ id="env_ id";
DELETE FROM session WHERE environment_ id="env_ id" ;
DELETE FROM environment WHERE id = "env_id";