diff --git a/service/docker-compose.yml b/service/docker-compose.yml index e3b1418..3e41896 100644 --- a/service/docker-compose.yml +++ b/service/docker-compose.yml @@ -22,6 +22,7 @@ services: db: image: mariadb:latest + command: --event-scheduler=ON volumes: - ./init.sql:/docker-entrypoint-initdb.d/init.sql - ./data/:/var/lib/mysql:Z diff --git a/service/init.sql b/service/init.sql index 5341c11..ee5257b 100644 --- a/service/init.sql +++ b/service/init.sql @@ -17,6 +17,7 @@ CREATE TABLE user( created DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ); GRANT UPDATE(plan) on user TO "web"; +CREATE EVENT cleanup_user ON SCHEDULE EVERY 5 SECOND DO DELETE FROM user WHERE TIMESTAMPDIFF(SECOND, created, CURRENT_TIME) > 600; use premium_forum; CREATE TABLE post( @@ -25,4 +26,4 @@ CREATE TABLE post( created DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ); CREATE INDEX post_thread_IDX ON post(thread); - +CREATE EVENT cleanup_post ON SCHEDULE EVERY 5 SECOND DO DELETE FROM post WHERE TIMESTAMPDIFF(SECOND, created, CURRENT_TIME) > 600;