X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=db.sql;h=23ccd1362ef4916c5760d3783ad9ee799d6133c2;hb=b6a6f3a06ee585c17fb7fe8c7aa5dae80e8db5d6;hp=cbc8b3c3a5c0b1fd0970833efbce9a59792794e7;hpb=61350d3c8d37c34cd66384e7170831a354a0ae0f;p=mudd.git diff --git a/db.sql b/db.sql index cbc8b3c..23ccd13 100644 --- a/db.sql +++ b/db.sql @@ -29,15 +29,17 @@ CREATE TABLE `messages` ( `source` int, `sent` timestamp default current_timestamp, PRIMARY KEY (`id`), - CONSTRAINT `origin` FOREIGN KEY (`source`) REFERENCES `players` (`id`), - CONSTRAINT `addressable` FOREIGN KEY (`destination`) REFERENCES `players` (`id`), + CONSTRAINT `origin` FOREIGN KEY (`source`) REFERENCES `players` (`id`) + ON DELETE CASCADE, + CONSTRAINT `addressable` FOREIGN KEY (`destination`) REFERENCES `players` (`id`) + ON DELETE CASCADE, CONSTRAINT `place` FOREIGN KEY (`room`) REFERENCES `rooms` (`id`) ); CREATE EVENT `purge_inactive_players` - ON SCHEDULE EVERY 1 MINUTE + ON SCHEDULE EVERY 1 MINUTE STARTS now() DO DELETE FROM `players` WHERE `last_active` < now() - interval 5 minute; CREATE EVENT `purge_old_messages` - ON SCHEDULE EVERY 1 MINUTE + ON SCHEDULE EVERY 1 MINUTE STARTS now() DO DELETE FROM `messages` WHERE `sent` < now() - interval 5 minute;