· 8 years ago · Jun 08, 2018, 01:38 AM
1create event if not exists alerts_remover
2 on schedule every 1 day
3 starts current_timestamp
4 comment 'Gets the old entry ids THEN drops them from the table EACH day.'
5 do delete from alerts where id in (
6 select id from alerts
7 where started_at < unix_timestamp(now() - interval 7 day)
8 order by started_at desc
9 );