Created
April 16, 2013 15:20
-
-
Save sycobuny/5396811 to your computer and use it in GitHub Desktop.
Cleaning out old OSSEC alerts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WITH | |
| del_data AS ( | |
| DELETE | |
| FROM data | |
| WHERE EXISTS ( | |
| SELECT id | |
| FROM alert | |
| WHERE timestamp <= EXTRACT(EPOCH FROM (NOW() - '1 year'::interval))::integer AND | |
| data.id = alert.id | |
| ) | |
| RETURNING id | |
| ) | |
| DELETE | |
| FROM alert | |
| WHERE EXISTS ( | |
| SELECT 1 | |
| FROM del_data | |
| WHERE alert.id = del_data.id | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment