Simple purge script for data pertaining to a specific participant
This commit is contained in:
parent
5ce866936d
commit
775fa3a7e2
23
misc/clear_entries_for_participant.sql
Normal file
23
misc/clear_entries_for_participant.sql
Normal file
@ -0,0 +1,23 @@
|
||||
DELETE FROM times WHERE
|
||||
times.shipcall_id IN
|
||||
(
|
||||
SELECT s.id FROM shipcall s
|
||||
JOIN shipcall_participant_map spm ON s.id = spm.shipcall_id
|
||||
JOIN participant p ON spm.participant_id = p.id
|
||||
WHERE p.id = 10
|
||||
);
|
||||
|
||||
DELETE `history` FROM `history`
|
||||
JOIN shipcall s on `history`.shipcall_id = s.id
|
||||
JOIN shipcall_participant_map spm ON s.id = spm.shipcall_id
|
||||
WHERE spm.participant_id = 10;
|
||||
|
||||
-- damit das hier funktioniert muss der FK in shipcall_participant_map von "RESTRICT" auf "SET NULL"
|
||||
-- geändert werden
|
||||
|
||||
DELETE shipcall FROM shipcall
|
||||
INNER JOIN shipcall_participant_map spm ON shipcall.id = spm.shipcall_id
|
||||
JOIN participant p ON spm.participant_id = p.id
|
||||
WHERE p.id = 10;
|
||||
|
||||
DELETE FROM shipcall_participant_map WHERE participant_id = 10;
|
||||
Reference in New Issue
Block a user