Skip to content

Commit

Permalink
chore: database cleanup script for closed events
Browse files Browse the repository at this point in the history
Details:
* used on demo/dev server to periodically cleanup old&closed events
  • Loading branch information
nimdanitro committed Feb 7, 2024
1 parent 984ee1f commit ff9bf8a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions scripts/cleanup-closed.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BEGIN TRANSACTION;

DELETE FROM divisions
WHERE incident_id IN (
SELECT id FROM incidents WHERE closed_at IS NOT NULL
);

DELETE FROM messages
WHERE journal_id IN (
SELECT id FROM journals
WHERE incident_id IN (
SELECT id FROM incidents WHERE closed_at IS NOT NULL
)
);

DELETE FROM journals
WHERE incident_id IN (
SELECT id FROM incidents WHERE closed_at IS NOT NULL
);


DELETE FROM incidents
WHERE closed_at IS NOT NULL;

COMMIT;

0 comments on commit ff9bf8a

Please sign in to comment.