Skip to content

Commit

Permalink
db: add database cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
RTUnreal committed May 22, 2024
1 parent f8fc396 commit 4c4eb20
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions service/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion service/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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;

0 comments on commit 4c4eb20

Please sign in to comment.