chore: update cleanup script

This commit is contained in:
Daniel Aschwanden
2024-05-10 14:10:08 +02:00
parent 22f7db2df5
commit acf9dff859
+18
View File
@@ -18,8 +18,26 @@ WHERE incident_id IN (
SELECT id FROM incidents WHERE closed_at IS NOT NULL
);
DELETE FROM features
WHERE layer_id IN (
SELECT id FROM layers
WHERE incident_id IN (
SELECT id FROM incidents WHERE closed_at IS NOT NULL
)
);
DELETE FROM layers
WHERE incident_id IN (
SELECT id FROM incidents WHERE closed_at IS NOT NULL
);
DELETE FROM incidents
WHERE closed_at IS NOT NULL;
COMMIT;
BEGIN TRANSACTION;
UPDATE incidents SET closed_at = now()
WHERE closed_at IS NULL AND created_at <= now() - interval '24 hours';
COMMIT;