'MariaDB. Create a trigger that deletes rows from a table older than 15 days

I want to create a database trigger that deletes automatically rows where the value of happened_at field is older than 15 days.

My table rows

id int(11)
site_id int(11)
user_id int(11)
data text
read bit(1)
deleted bit(1)
happened_at datetime

How can I do it?

I will try.

CREATE EVENT IF NOT EXISTS `clean_older_than_15_days_logs`
ON SCHEDULE
  EVERY 15 DAY
  COMMENT 'Clean up log connections at 1 AM.'
  DO
    DELETE FROM log
    WHERE happened_at < DATE_SUB(NOW(), INTERVAL 15 DAY);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source